Skip to content
Snippets Groups Projects
core1-dispatcher.c 850 B
Newer Older
  • Learn to ignore specific revisions
  • #include "board.h"
    #include "gpio.h"
    #include "mxc_delay.h"
    
    rahix's avatar
    rahix committed
    #include "api.h"
    
    rahix's avatar
    rahix committed
    #include "tmr_utils.h"
    
    ch3's avatar
    ch3 committed
    #include "api/api_dispatcher.h"
    
    
    static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
    
    
    rahix's avatar
    rahix committed
    void api_set_buzzer(uint8_t state)
    {
    	if (state) {
    		printf("API: Turning motor ON!\n");
    		GPIO_OutSet(&motor_pin);
    	} else {
    		printf("API: Turning motor OFF!\n");
    		GPIO_OutClr(&motor_pin);
    	}
    }
    
    void api_set_led(uint8_t led, led_color_t color)
    {
    	printf("API: Changing color of led %d.\n", led);
    	leds_set(led, color.red, color.green, color.blue);
    }
    
    
    int main(void)
    {
    
    ch3's avatar
    ch3 committed
    	api_init(NULL);
    
    rahix's avatar
    rahix committed
    
    	while (1) {
    		api_dispatcher();
                    TMR_Delay(MXC_TMR1, MSEC(100), 0);
    	}
    
    #if 0
    
    	// Enable rxev on core1
    	MXC_GCR->evten |= 0x20;
    	for (int i = 0; 1; i++) {
    		__asm volatile("wfe");
    		printf("core1: Hello! %d\n", i);
    	}
    
    rahix's avatar
    rahix committed
    #endif