void main(void) { #if !defined(MAX_UART_RX_BUF_CNT) #error "Define MAX_UART_RX_BUF_CNT > 0 in config.h for this example" #endif WD_STOP(); ClockConfig(16); HardwareInit(); // init uart at 115k UartInit(115200); _EINT(); printf("\n\nEnter your name: "); static uint8_t buf[30]; uint8_t* cur_char = &buf[0]; while(1) { // poll the rx buffer for new data if (!UartBufEmpty()) { // pull the data out one byte at a time *cur_char = getchar(); // was the last character a carriage return? if (*(cur_char - 1) == '\r') { printf("\nHello %s",buf); } } } }
void main(void) { #if defined(MAX_UART_RX_BUF_CNT) || defined(MAX_UART_TX_BUF_CNT) #error "Comment out MAX_UART_RX_BUF_CNT and MAX_UART_TX_BUF_CNT in config.h for this example" #endif WD_STOP(); ClockConfig(16); HardwareInit(); // init uart at 115k UartInit(115200); _EINT(); printf("\n\nEnter your name: "); static uint8_t buf[20]; uint8_t* cur_char = &buf[0]; while(1) { // The code will stop here and wait for a character to be received while((*cur_char++ = getchar()) == '\r') { printf("\nHello %s",buf); } } }
void main(void) { WD_STOP(); ClockConfig(1); HardwareInit(); ScheduleTimerInit(); BlinkLed1(); _EINT(); LPM0; }
void main(void) { WD_STOP(); ClockConfig(16); ScheduleTimerInit(); HardwareInit(); // call ToggleLed2 and it will continue to reschedule itself forever ToggleLed2(); _EINT(); LPM0; }
void main(void) { WD_STOP(); ClockConfig(16); ScheduleTimerInit(); HardwareInit(); // attach function to SW1 falling edge interrupt InterruptAttach(GPIO(SW1), QueueButton, FALLING); _EINT(); LPM0; }
void main(void) { WD_STOP(); ClockConfig(16); HardwareInit(); // Init the timer ScheduleTimerInit(); // register a function and define its period CallbackRegister(BlinkLed1, 100ul * _MILLISECOND); // attach function to SW1 falling edge interrupt InterruptAttach(GPIO(SW1),ToggleEnable,FALLING); _EINT(); LPM0; }
void main(void) { WD_STOP(); ClockConfig(16); HardwareInit(); // Init the timer ScheduleTimerInit(); // register functions and define their period CallbackRegister(BlinkLed1, 100ul * _MILLISECOND); CallbackRegister(BlinkLed2, 101ul * _MILLISECOND); // callbacks are disabled by default, so enable them CallbackMode(BlinkLed1, ENABLED); CallbackMode(BlinkLed2, ENABLED); _EINT(); LPM0; }
void main(void) { WD_STOP(); CAL_CLOCK(); // TimerAInit(); HardwareInit(); I2cInit(0x02, 0x00); _EINT(); while (1) { //LPM0; //_NOP(); if (GetWriteEndpoint(0)) SET_LOW(RED_LED); else SET_HIGH(RED_LED); SetReadEndpoint(0, READ_IN(LP_SWITCH)); } }
void main(void) { #if !defined(MAX_UART_TX_BUF_CNT) #error "Define MAX_UART_TX_BUF_CNT > 0 in config.h for this example" #endif WD_STOP(); ClockConfig(16); HardwareInit(); // init uart at 115k UartInit(115200); _EINT(); printf("\n\nThis is %s\n", "a string"); printf("Hex number(16): 0x%x\n", 60); printf("Hex number(32): 0x%lx\n", 100000); printf("Char: %c\n", 'x'); printf("Unsigned short: %u\n", 100); printf("Signed short: %i\n", -100); printf("Unsigned long: %lu\n", 250000); printf("Signed long: %li\n", -250000); LPM0; }