2012-03-05 15:47:01 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* uart write routines
|
|
|
|
*
|
|
|
|
* \author
|
|
|
|
*
|
|
|
|
* Anthony "Asterisk" Ambuehl
|
|
|
|
*
|
|
|
|
* interrupt routines which must be in HOME bank. handles received data from UART.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "cc253x.h"
|
|
|
|
|
|
|
|
#include "dev/uart0.h"
|
|
|
|
#include "dev/uart1.h"
|
|
|
|
#include "sys/energest.h"
|
|
|
|
|
|
|
|
#if UART0_ENABLE
|
2012-12-16 13:10:28 +00:00
|
|
|
static int (* uart0_input_handler)(unsigned char c);
|
2012-03-05 15:47:01 +00:00
|
|
|
#endif
|
|
|
|
#if UART1_ENABLE
|
2012-12-16 13:10:28 +00:00
|
|
|
static int (* uart1_input_handler)(unsigned char c);
|
2012-03-05 15:47:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UART0_ENABLE
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2012-12-16 13:10:28 +00:00
|
|
|
uart0_set_input(int (* input)(unsigned char c))
|
2012-03-05 15:47:01 +00:00
|
|
|
{
|
|
|
|
uart0_input_handler = input;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
#if UART0_CONF_WITH_INPUT
|
2012-09-05 15:00:23 +00:00
|
|
|
/* avoid referencing bits since we're not using them */
|
|
|
|
#pragma save
|
|
|
|
#if CC_CONF_OPTIMIZE_STACK_SIZE
|
|
|
|
#pragma exclude bits
|
|
|
|
#endif
|
2012-03-05 15:47:01 +00:00
|
|
|
void
|
2012-12-16 13:10:28 +00:00
|
|
|
uart0_rx_isr(void) __interrupt(URX0_VECTOR)
|
2012-03-05 15:47:01 +00:00
|
|
|
{
|
|
|
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
|
|
|
URX0IF = 0;
|
|
|
|
if(uart0_input_handler != NULL) {
|
|
|
|
uart0_input_handler(U0DBUF);
|
|
|
|
}
|
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
|
|
|
}
|
2012-09-05 15:00:23 +00:00
|
|
|
#pragma restore
|
2012-03-05 15:47:01 +00:00
|
|
|
#endif
|
|
|
|
#endif /* UART0_ENABLE */
|
|
|
|
#if UART1_ENABLE
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2012-12-16 13:10:28 +00:00
|
|
|
uart1_set_input(int (* input)(unsigned char c))
|
2012-03-05 15:47:01 +00:00
|
|
|
{
|
|
|
|
uart1_input_handler = input;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
#if UART_ONE_CONF_WITH_INPUT
|
2012-09-05 15:00:23 +00:00
|
|
|
/* avoid referencing bits since we're not using them */
|
|
|
|
#pragma save
|
|
|
|
#if CC_CONF_OPTIMIZE_STACK_SIZE
|
|
|
|
#pragma exclude bits
|
|
|
|
#endif
|
2012-03-05 15:47:01 +00:00
|
|
|
void
|
2012-12-16 13:10:28 +00:00
|
|
|
uart1_rx_isr(void) __interrupt(URX1_VECTOR)
|
2012-03-05 15:47:01 +00:00
|
|
|
{
|
|
|
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
|
|
|
URX1IF = 0;
|
|
|
|
if(uart1_input_handler != NULL) {
|
|
|
|
uart1_input_handler(U1DBUF);
|
|
|
|
}
|
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
|
|
|
}
|
2012-09-05 15:00:23 +00:00
|
|
|
#pragma restore
|
2012-03-05 15:47:01 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
#endif /* UART_ONE_CONF_WITH_INPUT */
|
|
|
|
#endif /* UART1_ENABLE */
|