2010-01-26 00:12:09 +01:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* uart write routines
|
|
|
|
*
|
|
|
|
* \author
|
|
|
|
*
|
|
|
|
* Anthony "Asterisk" Ambuehl
|
|
|
|
*
|
|
|
|
* interrupt routines which must be in HOME bank. handles received data from UART.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "cc2430_sfr.h"
|
|
|
|
|
|
|
|
#include "dev/leds.h"
|
2012-03-05 17:28:06 +01:00
|
|
|
#include "dev/uart0.h"
|
|
|
|
#include "dev/uart1.h"
|
|
|
|
#include "sys/energest.h"
|
2010-01-26 00:12:09 +01:00
|
|
|
|
2012-03-05 17:28:06 +01:00
|
|
|
#if UART_ZERO_ENABLE
|
2010-01-26 00:12:09 +01:00
|
|
|
static int (*uart0_input_handler)(unsigned char c);
|
2012-03-05 17:28:06 +01:00
|
|
|
#endif
|
|
|
|
#if UART_ONE_ENABLE
|
2010-01-26 00:12:09 +01:00
|
|
|
static int (*uart1_input_handler)(unsigned char c);
|
2012-03-05 17:28:06 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UART_ZERO_ENABLE
|
2010-01-26 00:12:09 +01:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
uart0_set_input(int (*input)(unsigned char c))
|
|
|
|
{
|
|
|
|
uart0_input_handler = input;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2012-03-05 17:28:06 +01:00
|
|
|
uart0_rx_ISR(void) __interrupt (URX0_VECTOR)
|
2010-01-26 00:12:09 +01:00
|
|
|
{
|
2012-03-05 17:28:06 +01:00
|
|
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
2010-01-26 00:12:09 +01:00
|
|
|
TCON_URX0IF = 0;
|
|
|
|
if(uart0_input_handler != NULL) {
|
|
|
|
uart0_input_handler(U0BUF);
|
|
|
|
}
|
2012-03-05 17:28:06 +01:00
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
2010-01-26 00:12:09 +01:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2012-03-05 17:28:06 +01:00
|
|
|
uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR)
|
2010-01-26 00:12:09 +01:00
|
|
|
{
|
|
|
|
}
|
2012-03-05 17:28:06 +01:00
|
|
|
#endif /* UART_ZERO_ENABLE */
|
|
|
|
#if UART_ONE_ENABLE
|
2010-01-26 00:12:09 +01:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
uart1_set_input(int (*input)(unsigned char c))
|
|
|
|
{
|
|
|
|
uart1_input_handler = input;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2012-03-05 17:28:06 +01:00
|
|
|
#if UART_ONE_CONF_WITH_INPUT
|
2010-01-26 00:12:09 +01:00
|
|
|
void
|
2012-03-05 17:28:06 +01:00
|
|
|
uart1_rx_ISR(void) __interrupt (URX1_VECTOR)
|
2010-01-26 00:12:09 +01:00
|
|
|
{
|
2012-03-05 17:28:06 +01:00
|
|
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
2010-01-26 00:12:09 +01:00
|
|
|
TCON_URX1IF = 0;
|
|
|
|
if(uart1_input_handler != NULL) {
|
|
|
|
uart1_input_handler(U1BUF);
|
|
|
|
}
|
2012-03-05 17:28:06 +01:00
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
2010-01-26 00:12:09 +01:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2012-03-05 17:28:06 +01:00
|
|
|
uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR)
|
2010-01-26 00:12:09 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2012-03-05 17:28:06 +01:00
|
|
|
#endif /* UART_ONE_CONF_WITH_INPUT */
|
|
|
|
#endif /* UART_ONE_ENABLE */
|