Skip to content
Snippets Groups Projects
Commit 1ec114d1 authored by Edward Longman's avatar Edward Longman
Browse files

Add libary usage to minimal example

parent a8a74a36
No related branches found
No related tags found
No related merge requests found
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
)
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* LOCAL FUNCTIONS * LOCAL FUNCTIONS
*/ */
extern void msp_setup(void); extern void msp_setup(void);
extern unsigned long volatile time_counter; unsigned long volatile time_counter;
/****************************************************************************** /******************************************************************************
* GLOBALS * GLOBALS
...@@ -57,7 +57,7 @@ void main (void) ...@@ -57,7 +57,7 @@ void main (void)
msp_setup(); msp_setup();
/* Initialize the UART port */ /* Initialize the UART port */
//hal_uart_init(); hal_uart_init();
/* enable uart echo function */ /* enable uart echo function */
//uart_drv_toggle_echo(); //uart_drv_toggle_echo();
...@@ -94,8 +94,9 @@ void main (void) ...@@ -94,8 +94,9 @@ void main (void)
{ {
/* Put MCU in low power mode, wait for UART and blink LED */ /* Put MCU in low power mode, wait for UART and blink LED */
//Skip Low power mode to debug
HAL_LED2_OFF(); HAL_LED2_OFF();
_BIS_SR(LPM0_bits + GIE); //_BIS_SR(LPM0_bits + GIE);
HAL_LED2_ON(); HAL_LED2_ON();
idle_counter++; idle_counter++;
...@@ -105,15 +106,23 @@ void main (void) ...@@ -105,15 +106,23 @@ void main (void)
*/ */
switch(state) switch(state)
{ {
/* print the main menu to the UART buffer */ /* print the tick state to the UART buffer */
case WAIT: case WAIT:
if(idle_counter>250){ if(time_counter>5){
state = IDLE_RESET; state = IDLE_RESET;
uartSendString("Tic:\n\r");
time_counter = 0;
} }
state = OPERATE; state = OPERATE;
HAL_LED1_OFF();
break; break;
case OPERATE: case OPERATE:
state = OPERATE; if(time_counter>5){
state = WAIT;
uartSendString("Tic:\n\r");
time_counter = 0;
}
HAL_LED1_ON();
break; break;
default: default:
state = WAIT; state = WAIT;
...@@ -121,3 +130,63 @@ void main (void) ...@@ -121,3 +130,63 @@ void main (void)
} }
} }
} }
/******************************************************************************
* @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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment