Changeset 1463
- Timestamp:
- 02/25/12 21:26:00 (15 months ago)
- Location:
- trunk/firmware/openos
- Files:
-
- 7 edited
-
bsp/spi.h (modified) (2 diffs)
-
bsp/telosb/board.c (modified) (1 diff)
-
bsp/telosb/spi.c (modified) (2 diffs)
-
bsp/telosb/uart.c (modified) (3 diffs)
-
bsp/uart.h (modified) (2 diffs)
-
projects/telosb/01-bsp/01bsp_radio.c (modified) (2 diffs)
-
projects/telosb/01-bsp/01bsp_uart.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/firmware/openos/bsp/spi.h
r1455 r1463 43 43 } spi_last_t; 44 44 45 typedef void (*spi Callback_t)(void);45 typedef void (*spi_cbt)(void); 46 46 47 47 //=========================== variables ======================================= … … 51 51 void spi_init(); 52 52 #ifdef SPI_IN_RTOS_MODE 53 void spi_setCallback(spi Callback_t cb);53 void spi_setCallback(spi_cbt cb); 54 54 #endif 55 55 void spi_txrx(uint8_t* bufTx, -
trunk/firmware/openos/bsp/telosb/board.c
r1457 r1463 31 31 leds_init(); 32 32 uart_init(); 33 spi_init(); 34 radio_init(); 35 radiotimer_init(); 33 //spi_init(); 34 //radio_init(); 35 //radiotimer_init(); 36 37 __bis_SR_register(GIE); 36 38 } 37 39 -
trunk/firmware/openos/bsp/telosb/spi.c
r1462 r1463 29 29 #ifdef SPI_IN_RTOS_MODE 30 30 // callback when module done 31 spi Callback_tcallback;31 spi_cbt callback; 32 32 #endif 33 33 } spi_vars_t; … … 102 102 103 103 #ifdef SPI_IN_RTOS_MODE 104 void spi_setCallback(spi Callback_t cb) {104 void spi_setCallback(spi_cbt cb) { 105 105 spi_vars.callback = cb; 106 106 } -
trunk/firmware/openos/bsp/telosb/uart.c
r1415 r1463 7 7 #include "msp430f1611.h" 8 8 #include "stdint.h" 9 #include "stdio.h" 9 10 #include "uart.h" 10 11 11 12 //=========================== defines ========================================= 12 13 13 #define BAUDRATE_11520014 15 14 //=========================== variables ======================================= 16 15 17 16 typedef struct { 18 uint8_t callBack; 17 // TX 18 uint8_t* txBuf; 19 uint8_t txBufLen; 20 uart_cbt txDone_cb; 21 // RX 22 uint8_t* rxBuffer; 23 uint8_t rxBytesReceived; 24 uint8_t rxBytesTreshold; 25 uart_cbt rxThreshold_cb; 19 26 } uart_vars_t; 20 27 … … 28 35 P3SEL = 0xC0; // P3.6,7 = UART1TX/RX 29 36 30 ME2 |= UTXE1 + URXE1; // enable UART1 TX/RX37 UCTL1 = SWRST; // hold UART1 module in reset 31 38 UCTL1 |= CHAR; // 8-bit character 32 39 33 #ifdef BAUDRATE_11520040 #ifdef UART_BAUDRATE_115200 34 41 //115200 baud, clocked from 4.8MHz SMCLK 35 42 UTCTL1 |= SSEL1; // clocking from SMCLK … … 45 52 #endif 46 53 54 ME2 |= UTXE1 + URXE1; // enable UART1 TX/RX 47 55 UCTL1 &= ~SWRST; // clear UART1 reset bit 48 //IE2 |= URXIE1; // enable UART1RX interrupt56 IE2 |= UTXIE1 + URXIE1; // enable UART1 TX/RX interrupt 49 57 } 50 58 51 void uart_tx(uint8_t c) { 52 U1TXBUF = c; 59 void uart_setTxDoneCb(uart_cbt cb) { 60 uart_vars.txDone_cb = cb; 61 } 62 63 void uart_setRxThresholdCb(uart_cbt cb) { 64 uart_vars.rxThreshold_cb = cb; 65 } 66 67 void uart_tx(uint8_t* txBuf, uint8_t txBufLen) { 68 69 // register data to send 70 uart_vars.txBuf = txBuf; 71 uart_vars.txBufLen = txBufLen; 72 73 // send first byte 74 U1TXBUF = *uart_vars.txBuf; 53 75 } 54 76 55 77 //=========================== private ========================================= 78 79 //=========================== interrupt handlers ============================== 80 81 #pragma vector = USART1TX_VECTOR 82 __interrupt void usart1tx_VECTOR (void) { 83 // one byte less to go 84 uart_vars.txBufLen--; 85 uart_vars.txBuf++; 86 87 if (uart_vars.txBufLen>0) { 88 // send next byte 89 U1TXBUF = *uart_vars.txBuf; 90 } else { 91 if (uart_vars.txDone_cb!=NULL) { 92 uart_vars.txDone_cb(); 93 } 94 } 95 } 96 97 #pragma vector = USART1RX_VECTOR 98 __interrupt void usart1rx_VECTOR (void) { 99 P5OUT ^= 0x10; // toggle LED 100 } -
trunk/firmware/openos/bsp/uart.h
r1415 r1463 12 12 //=========================== define ========================================== 13 13 14 //#define UART_BAUDRATE_115200 15 14 16 //=========================== typedef ========================================= 17 18 typedef void (*uart_cbt)(void); 15 19 16 20 //=========================== variables ======================================= … … 19 23 20 24 void uart_init(); 21 void uart_tx(uint8_t c); 25 void uart_setTxDoneCb(uart_cbt cb); 26 void uart_setRxThresholdCb(uart_cbt cb); 27 void uart_tx(uint8_t* txBuf, uint8_t txBufLen); 22 28 23 29 #endif -
trunk/firmware/openos/projects/telosb/01-bsp/01bsp_radio.c
r1461 r1463 18 18 //=========================== variables ======================================= 19 19 20 void cb_radioTimerOverflows();21 void cb_radioTimerCompare();22 void cb_startFrame(uint16_t timestamp);23 void cb_endFrame(uint16_t timestamp);24 25 20 typedef struct { 26 21 uint8_t radio_busy; … … 32 27 33 28 app_vars_t app_vars; 29 30 //=========================== prototypes ====================================== 31 32 void cb_radioTimerOverflows(); 33 void cb_radioTimerCompare(); 34 void cb_startFrame(uint16_t timestamp); 35 void cb_endFrame(uint16_t timestamp); 34 36 35 37 //=========================== main ============================================ -
trunk/firmware/openos/projects/telosb/01-bsp/01bsp_uart.c
r1421 r1463 10 10 #include "uart.h" 11 11 12 //=========================== defines ========================================= 13 14 uint8_t stringToSend[] = "Hello World!"; 15 16 //=========================== variables ======================================= 17 18 typedef struct { 19 uint8_t uart_busy; 20 } app_vars_t; 21 22 app_vars_t app_vars; 23 24 //=========================== prototypes ====================================== 25 26 void cb_uartDone(); 27 28 //=========================== main ============================================ 29 12 30 /** 13 31 \brief The program starts executing here. … … 17 35 board_init(); 18 36 19 while (1) { 20 uart_tx('a'); 37 uart_setTxDoneCb(cb_uartDone); 38 39 uart_tx(&stringToSend[0],sizeof(stringToSend)); 40 41 app_vars.uart_busy = 1; 42 while (app_vars.uart_busy==1) { 21 43 } 44 45 // go back to sleep 46 board_sleep(); 22 47 } 48 49 //=========================== callbacks ======================================= 50 51 void cb_uartDone() { 52 app_vars.uart_busy = 0; 53 }
Note: See TracChangeset
for help on using the changeset viewer.
