#include <string.h>
#include <pxmc.h>
-#include <pxmc_h2638.h>
+#include <pxmcbsp.h>
#include <cmd_proc.h>
#include "cmd_pxmc.h"
#include "timer3.h"
#include <stdio.h>
+cmd_des_t const *cmd_rs232_default[];
/*struktury prikazu cmd*/
cmd_des_t const cmd_des_help={0, 0,"HELP","prints help for commands",
- cmd_do_help,{(char*)&cmd_rs232}};
+ cmd_do_help,{(char*)&cmd_rs232_default}};
cmd_des_t const *cmd_rs232_default[]={
&cmd_des_help,
- CMD_DES_CONTINUE_AT, /* list continues at new address */
- (cmd_des_t*)cmd_pxmc_default,
+ CMD_DES_CONTINUE_AT(cmd_pxmc_default),
NULL
};
cmd_des_t const **cmd_bth=cmd_rs232_default; /*cmd prikazy pro bth*/
};
//********************************************************
-
-int cmd_rs232_processor_run(void)
-{
- int val;
- cmd_io_t* cmd_io;
-
- cmd_io=&cmd_io_rs232;
- if(cmd_rs232_line_out(cmd_io))
- return 1;
-
- if(cmd_rs232_line_in(cmd_io)<=0)
- return 0;
-
- if(cmd_rs232){
- val=proc_cmd_line(cmd_io, cmd_rs232, cmd_io->priv.ed_line.in->buf);
- }else{
- val=-CMDERR_BADCMD;
- }
-
- if(cmd_io->priv.ed_line.out->inbuf){
- cmd_io_putc(cmd_io,'\r');
- cmd_io_putc(cmd_io,'\n');
-
- }else if(val<0){
- char s[20];
- cmd_io_write(&cmd_io_rs232,"ERROR ",6);
- i2str(s,-val,0,0);
- cmd_io_write(cmd_io,s,strlen(s));
- cmd_io_putc(cmd_io,'\r');
- cmd_io_putc(cmd_io,'\n');
- }
- return 1;
-}
+extern cmd_io_t cmd_io_rs232_line;
extern void _print(char *str);
_print("Start\n");
- /*nastaveni HW (TPU, PWM)*/
- pxmc_set_pwm_tpu();
-
- /*nastaveni DC motoru*/
- pxmc_add_pservice_and_mode(4); /*Macro - mod=4 tj. all motors are DC*/
+ pxmc_initialize();
if (init_timer3((long long)200/*ms*/*1000*1000) < 0) {
/* ERROR */
int speed = 3000;
int radius = 0;
while (1) {
- cmd_rs232_processor_run(); /*sber + odesilani cmd prikazu PC*/
+ cmd_processor_run(&cmd_io_rs232_line, cmd_rs232_default);
long int now = get_timer();
if (now > before) {
before = now;
- DEB_LED_XOR(1);
+// DEB_LED_XOR(1);
}
if (now >= next) {
- DEB_LED_XOR(3);
+// DEB_LED_XOR(3);
next = now + 1 + (rand() % 5);
//printf("%5ld->%5ld ", now, next);
if (rand() % 100 < 20)