17 #include "libschedule/schedule.h"
23 #include "inc/hw_memmap.h"
25 #include "driverlib/adc.h"
26 #include "driverlib/sysctl.h"
27 #include "driverlib/gpio.h"
28 #include "driverlib/interrupt.h"
29 #include "driverlib/uart.h"
30 #include "driverlib/pwm.h"
35 os_surrender_context(); \
56 #define can_data_length 10
62 #define UART0_RX_BUFFER_SIZE 8
74 #define BLINK_RED_WAIT_FOR_SEM 1
75 #define BLINK_BLUE_WAIT_FOR_SEM 1
76 #define BLINK_GREEN_WAIT_FOR_SEM 1
81 #if BLINK_RED_WAIT_FOR_SEM == 1
82 if (sem_blink_red.
guard()) {
86 #if BLINK_RED_WAIT_FOR_SEM == 1
89 os_surrender_context();
96 #if BLINK_BLUE_WAIT_FOR_SEM == 1
97 if (sem_blink_blue.
guard()) {
101 #if BLINK_BLUE_WAIT_FOR_SEM == 1
104 os_surrender_context();
111 #if BLINK_GREEN_WAIT_FOR_SEM == 1
112 if (sem_blink_green.
guard()) {
116 #if BLINK_GREEN_WAIT_FOR_SEM == 1
119 os_surrender_context();
135 if(!(uart0.
ack() & (UART_INT_RX | UART_INT_RT))) {
139 while(UARTCharsAvail(UART0_BASE)) {
159 UART0_RX_BUFFER.
notify((
const int8_t) recv);
166 uint32_t message_id = can0.
ack();
186 const uint32_t counter_max = SysCtlClockGet()/25;
187 uint32_t pins, counter;
204 while (++counter < counter_max) { }
209 os_surrender_context();
225 if (can_msg_id == 0) {
244 os_surrender_context();
251 if(UART0_RX_SEM.
guard()) {
254 char recv = UART0_RX_BUFFER.
get(ok);
256 if(ok) { shell0.
accept(recv); }
258 os_surrender_context();
266 if(motor_start.
guard()) {
269 if(motor_stop.
guard()) {
272 os_surrender_context();
283 countdown_timer.
ack();
292 os_surrender_context();
301 blink =
blinker(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
308 uart0 =
uart(UART0_BASE, INT_UART0);
314 shell0 =
shell(&uart0, &motor_start, &motor_stop);
315 motor0 =
motor(GPIO_PORTA_BASE, GPIO_PIN_6, PWM0_BASE, PWM_GEN_0, PWM_OUT_0);
316 motor1 =
motor(GPIO_PORTA_BASE, GPIO_PIN_7, PWM0_BASE, PWM_GEN_0, PWM_OUT_1);
317 drive0 =
drive(&motor0, &motor1, 50);
318 countdown_timer =
timer(0, TIMER_BOTH, TIMER_CFG_ONE_SHOT, SysCtlClockGet()*180,
319 TIMER_TIMA_TIMEOUT,
true);
320 switch0 =
lswitch(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,
321 &sem_switch, 1, TIMER_A, GPIO_BOTH_EDGES,
322 INT_GPIOE_TM4C123,
true);
static semaphore UART0_RX_SEM
void atomic_printf(const char *pcString,...)
semaphore sem_blink_green
virtual uint32_t ack(void)
void notify(const T data)
void steer(uint32_t left_sens, uint32_t left_front_sens, uint32_t right_sens, uint32_t right_front_sens, uint32_t front_sens)
uint16_t sens_ir_right_front
void thread_uart_update()
const uint32_t can_msg_id
uint16_t sens_ir_left_front
uint32_t end_debounce(void)
virtual uint32_t ack(void)
uint32_t blink_count_blue
uint32_t blink_count_green
void __cxa_pure_virtual()
static buffer< char, 8 > UART0_RX_BUFFER
static void set_clock(void)
virtual uint32_t ack(void)
virtual void blink(pin_t pin)
void thread_blink_green()
virtual void toggle(pin_t pin)