diff --git a/source/lib/uart_drv/CMakeLists.txt b/source/lib/uart_drv/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3a13fb28ca152554ada0b9944564ff21d1c451f7 --- /dev/null +++ b/source/lib/uart_drv/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8) + +include(${CMAKE_SOURCE_DIR}/../common.cmake) + + +add_library( + uart_drv + STATIC + circ_buf.c + uart_drv.c + ee_printf.c + ) diff --git a/source/test/min.c b/source/test/min.c index 23d216c02657358e0b150de4b5f253c9043efc6a..56ac5fba6ae8b23ab9a23b0aa92c1d8c3683e57d 100644 --- a/source/test/min.c +++ b/source/test/min.c @@ -10,7 +10,7 @@ * LOCAL FUNCTIONS */ extern void msp_setup(void); -extern unsigned long volatile time_counter; +unsigned long volatile time_counter; /****************************************************************************** * GLOBALS @@ -53,11 +53,11 @@ void main (void) WDTCTL = WDTPW + WDTHOLD; /* Setup MSP specific functions, IO's, timers and WDT */ - //Comes from lib/hal_mcu/hal_mcu.c + //Comes from lib/hal_mcu/hal_mcu.c msp_setup(); /* Initialize the UART port */ - //hal_uart_init(); + hal_uart_init(); /* enable uart echo function */ //uart_drv_toggle_echo(); @@ -94,8 +94,9 @@ void main (void) { /* Put MCU in low power mode, wait for UART and blink LED */ + //Skip Low power mode to debug HAL_LED2_OFF(); - _BIS_SR(LPM0_bits + GIE); + //_BIS_SR(LPM0_bits + GIE); HAL_LED2_ON(); idle_counter++; @@ -105,19 +106,87 @@ void main (void) */ switch(state) { - /* print the main menu to the UART buffer */ + /* print the tick state to the UART buffer */ case WAIT: - if(idle_counter>250){ - state = IDLE_RESET; - } + if(time_counter>5){ + state = IDLE_RESET; + uartSendString("Tic:\n\r"); + time_counter = 0; + } state = OPERATE; - break; - case OPERATE: - state = OPERATE; - break; + HAL_LED1_OFF(); + break; + case OPERATE: + if(time_counter>5){ + state = WAIT; + uartSendString("Tic:\n\r"); + time_counter = 0; + } + HAL_LED1_ON(); + break; default: state = WAIT; break; } } } + + +/****************************************************************************** + * @fn uartSendString + * + * @brief Implements a simple uart string sender by automatically finding + * the end of line delimeter and using it to call the uart sub + * functions + * + * input parameters + * + * @param unsigned char *str + * + * output parameters + * + * @return void + * + */ +void uartSendString(char *str) +{ + unsigned char ii; + + for(ii=0;ii<UART_BUFF_SIZE;ii++) + { + if(str[ii] == 13) + { + uart_put_str(str, ii+1); + ii = UART_BUFF_SIZE; + } + } + return; +} + +/****************************************************************************** + * @fn wdt_isr + * + * @brief Interrupt service routine for watch dog timer. + * + * input parameters + * + * @param void + * + * output parameters + * + * @return void + * + */ +HAL_ISR_FUNC_DECLARATION(wdt_isr,WDT) +{ + /* global "0.5 second" counter used for printing time stamped packet sniffer data */ + time_counter++; + + /* check to see if wake on wdt is enabled */ + if(wakeup_on_wdt == 1) + { + + /* exit from low power mode on ISR exit */ + //_BIC_SR_IRQ(LPM3_bits); + } +}