* YE BE WARNED
*/
void __attribute__ ((naked)) _reset_vector__(void) {
+ __asm__ __volatile__("mov #0xffb0,r1"::);
__asm__ __volatile__("br #main"::);
}
+
int main(void){
int16_t tmp;
PAOUT = 0x0000;
PAOEN = 0x0010; // set data direction registers
- UART0_BCR = BCR(DEVBOARD_CLOCK, BAUDRATE);
+ UART0_BCR = UART_BCR(DEVBOARD_CLOCK, BAUDRATE);
UART0_CR = UARTEn;
// a read clears the register -- ready for TX/RX
*
* word "exit" makes processLoop() return
*/
- init_msp4th();
- processLoop();
+ while (1) {
+ init_msp4th();
+ processLoop();
+ }
return 0;
}
void uart_putchar(uint8_t c)
{
- while ((UART0_SR & (TDRE | TXEMPTY)) == 0) {
+ while ((UART0_SR & (UART_TDRE | UART_TXEMPTY)) == 0) {
// wait for register to clear
}
UART0_TDR = (c & 0xff);
{
uint8_t c;
- while ((UART0_SR & RDRF) == 0) {
+ while ((UART0_SR & UART_RDRF) == 0) {
// wait for char
}
c = (UART0_RDR & 0x00ff);
#include "ns430.h"
/* UARTx_CR bits */
-#define TDRE_IE (1 << 0)
-#define TXEMPTY_IE (1 << 1)
-#define RDRF_IE (1 << 2)
-#define OVER_IE (1 << 3)
-#define PE_IE (1 << 4)
-#define FE_IE (1 << 5)
-#define Parity (1 << 6)
-#define UARTEn (1 << 7)
-#define LLEN (1 << 9)
-#define PAR_En (1 << 10)
+#define UART_TDRE_IE (1 << 0)
+#define UART_TXEMPTY_IE (1 << 1)
+#define UART_RDRF_IE (1 << 2)
+#define UART_OVER_IE (1 << 3)
+#define UART_PE_IE (1 << 4)
+#define UART_FE_IE (1 << 5)
+#define UART_Parity (1 << 6)
+#define UARTEn (1 << 7)
+#define UART_LLEN (1 << 9)
+#define UART_PAR_En (1 << 10)
/* UARTx_BCR
* 11-bit number
* BCR = (CLK / (16 * Baud)) - 1
*/
-#define BCR(c, b) ((c / (16 * b)) - 1)
+#define UART_BCR(c, b) ((c / (16 * b)) - 1)
/* UARTx_SR bits */
-#define TDRE (1 << 0)
-#define TXEMPTY (1 << 1)
-#define RDRF (1 << 2)
-#define OVER (1 << 3)
-#define PE (1 << 4)
-#define FE (1 << 5)
+#define UART_TDRE (1 << 0)
+#define UART_TXEMPTY (1 << 1)
+#define UART_RDRF (1 << 2)
+#define UART_OVER (1 << 3)
+#define UART_PE (1 << 4)
+#define UART_FE (1 << 5)
void uart_putchar(uint8_t c);
uint8_t uart_getchar(void);