diff --git a/tests/cputest.c b/tests/cputest.c index 36bac9b..1368cd3 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -40,7 +40,10 @@ #include "msp430setup.h" #include #include -#if __MSPGCC__ +#if defined(__GNUC__) && (__GNUC__ >= 9) +#include +#include +#elif __MSPGCC__ #include #include #define eint() __eint() @@ -79,7 +82,7 @@ static int caseID = 0; /*---------------------------------------------------------------------------*/ static int pos = 0; static unsigned int times[10]; -interrupt(TIMERB1_VECTOR) timerb1 (void) +ISR(TIMERB1, timerb1) { if(TBIV == 2) { if(pos < 10) { @@ -266,7 +269,7 @@ static void testBitFields() { /*--------------------------------------------------------------------------*/ static int flag; -interrupt(UART0TX_VECTOR) usart_tx_test0 (void) +ISR(USART0TX, usart_tx_test0) { printf("*IRQ: Flags:%d %d\n", IFG1, UTCTL0); flag++; diff --git a/tests/msp430setup.c b/tests/msp430setup.c index 9012f9c..d13e91c 100644 --- a/tests/msp430setup.c +++ b/tests/msp430setup.c @@ -37,7 +37,9 @@ */ #include "msp430setup.h" -#if __MSPGCC__ +#if defined(__GNUC__) && (__GNUC__ >= 9) +#include +#elif __MSPGCC__ #include #include #include @@ -49,7 +51,6 @@ #endif /* __MSPGCC__ */ #include - /*--------------------------------------------------------------------------*/ /* RS232 Interface */ /*--------------------------------------------------------------------------*/ @@ -57,8 +58,7 @@ static int (* input_handler)(unsigned char) = NULL; /*---------------------------------------------------------------------------*/ -interrupt(UART1RX_VECTOR) - rs232_rx_usart1(void) +ISR(USART1RX, rs232_rx_usart1) { /* Check status register for receive errors. - before reading RXBUF since it clears the error and interrupt flags */ @@ -129,12 +129,24 @@ rs232_set_input(int (*f)(unsigned char)) input_handler = f; } /*--------------------------------------------------------------------------*/ +#if defined(__GNUC__) && (__GNUC__ >= 9) +int +write(int fd, const char *buf, int len) +{ + int i = 0; + for(; i < len && buf[i]; i++) { + rs232_send(buf[i]); + } + return i; +} +#else int putchar(int c) { rs232_send(c); return c; } +#endif /*--------------------------------------------------------------------------*/ diff --git a/tests/msp430setup.h b/tests/msp430setup.h index 939507b..7a94fa7 100644 --- a/tests/msp430setup.h +++ b/tests/msp430setup.h @@ -39,6 +39,15 @@ #ifndef __MSP430SETUP_H__ #define __MSP430SETUP_H__ +#if defined(__GNUC__) && (__GNUC__ >= 9) +#define ISR(a,b) void __attribute__((interrupt(a ## _VECTOR))) b(void) +#define eint() __eint() +#define dint() __dint() +#elif defined(__GNUC__) && defined(__MSP430__) + /* This is the MSPGCC compiler */ +#define ISR(a,b) interrupt(a ## _VECTOR) b(void) +#endif + void msp430_setup(void); #define RS232_19200 1 diff --git a/tests/timertest.c b/tests/timertest.c index 12d6b20..f266197 100644 --- a/tests/timertest.c +++ b/tests/timertest.c @@ -38,7 +38,9 @@ */ #include "msp430setup.h" -#if __MSPGCC__ +#if defined(__GNUC__) && (__GNUC__ >= 9) +#include +#elif __MSPGCC__ #include #include #else /* __MSPGCC__ */ @@ -80,7 +82,7 @@ static volatile unsigned int count = 0; static volatile unsigned int seconds = 0; static volatile unsigned int last_tar = 0; -interrupt(TIMERA1_VECTOR) timera1 (void) +ISR(TIMERA1, timera1) { if(TAIV == 2) { eint(); @@ -104,7 +106,7 @@ interrupt(TIMERA1_VECTOR) timera1 (void) /*---------------------------------------------------------------------------*/ -interrupt(TIMERA0_VECTOR) timera0 (void) +ISR(TIMERA0, timera0) { ticka0++; TACCR0 += 4;