8 #include "linear_actuator/s02V2.h"
9 #include "hal/AT91SAM7S256.h"
10 #include "linear_actuator/board.h"
11 #include "linear_actuator/s02V2.h"
20 #define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL + 4096 )
24 bool new_command
= false;
25 volatile int position
= 0;
33 # error MODULE_ID not defined
36 extern "C" void recieve_data0(void *ptr
) {
37 struct uart_t
*uart
= (struct uart_t
*)ptr
;
39 static int pose_id
= MODULE_ID
+3;
41 uart_recieve_data(uart
, &buffer
, 28);
43 if(buffer
[2] == TYPE_ID
)
45 printf("Requested redefinition of gait ID\n");
46 for (int i
=3;i
<28;i
++)
48 if(buffer
[i
] == MODULE_ID
)
51 printf("Recieved column id: %d\n",pose_id
-3);
56 if(buffer
[2] == TYPE_POSE
)
58 position
= buffer
[pose_id
];
59 printf("Recieved pose %d\n",position
);
60 if ((position
> 0 && position
< 62) || position
== 87)
64 buffer
[0] &= 127; // set bit 0 to 0
65 //buffer[1] = MODULE_ID;
66 //uart_send_message(uart,buffer,28);
72 /* Set up system LED (SYSLED) and Power Control pin (PWRCTRL) */
73 AT91C_BASE_PIOA
->PIO_PER
= (SYSLED
|PWRCTRL
);
74 AT91C_BASE_PIOA
->PIO_OER
= (SYSLED
|PWRCTRL
);
75 AT91C_BASE_PIOA
->PIO_SODR
= (SYSLED
|PWRCTRL
);
77 struct uart_t
*uart1
= create_uart (1);
78 struct uart_t
*uart0
= create_uart (0);
80 uart_tie (uart0
, uart1
);
82 uart_register_recieve_callback(uart0
,recieve_data0
,uart0
,1);
83 uart_register_recieve_callback(uart1
,recieve_data0
,uart1
,1);
85 printf("MODULE_ID: %X\n",MODULE_ID
);