Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • koalo/bhi160documentation
  • genofire/rockets-state
  • schneider/max30001
  • schneider/stream-locks
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
29 results

main.c

Blame
  • Forked from card10 / firmware
    1844 commits behind, 1 commit ahead of the upstream repository.
    main.c 2.53 KiB
    /*******************************************************************************
     * License: TBD
     ******************************************************************************/
    
    /***** Includes *****/
    #include "pmic.h"
    #include "leds.h"
    #include "card10.h"
    
    #include "GUI_Paint.h"
    
    #include "tmr_utils.h"
    
    #include <stdio.h>
    #include <stdint.h>
    #include <string.h>
    #include <Heart.h>
    
    /***** Definitions *****/
    
    /***** Globals *****/
    static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
    
    void Core1_Start(void) {
        //MXC_GCR->gp0 = (uint32_t)(&__isr_vector_core1);
        MXC_GCR->gp0 = 0x10040000;
        MXC_GCR->perckcn1 &= ~MXC_F_GCR_PERCKCN1_CPU1;
    }
    
    void Core1_Stop(void) {
        MXC_GCR->perckcn1 |= MXC_F_GCR_PERCKCN1_CPU1;
    }
    
    int main(void)
    {
        int count = 0;
    
        card10_init();
        //card10_diag();
    
        GPIO_Config(&motor_pin);
    
        Paint_DrawImage(Heart, 0, 0, 160, 80);
        LCD_Update();
    
        for(int i=0; i<11; i++) {
            leds_set_dim(i, 1);
        }
    
        int h = 0;
        Core1_Start();
    
        while (1) {
    
    #if 1
            #define NUM     15
            for(int i=0; i<NUM; i++) {
                if(i < 12) {
                    leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1./8);
                } else {
                    leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1.);
                }
            }
            //leds_set_hsv(0, h, 1., 1.);
            //leds_set_hsv(1, (h + 90) % 360, 1., 1./2);
            //leds_set_hsv(2, (h + 180) % 360, 1., 1./2);
            //leds_set_hsv(3, (h + 270) % 360, 1., 1./2);
    
            leds_update();
            TMR_Delay(MXC_TMR0, MSEC(10), 0);
            h++;
    #endif
    #if 0
            pmic_set_led(0, 31);
            pmic_set_led(1, 0);
            pmic_set_led(2, 0);
            TMR_Delay(MXC_TMR0, MSEC(200), 0);
    
            pmic_set_led(0, 0);
            pmic_set_led(1, 31);
            pmic_set_led(2, 0);
            TMR_Delay(MXC_TMR0, MSEC(200), 0);
    
            pmic_set_led(0, 0);
            pmic_set_led(1, 0);
            pmic_set_led(2, 31);
            TMR_Delay(MXC_TMR0, MSEC(200), 0);
    
            pmic_set_led(0, 0);
            pmic_set_led(1, 0);
            pmic_set_led(2, 0);
            //TMR_Delay(MXC_TMR0, MSEC(200), 0);
    #endif
    #if 0
            //TMR_Delay(MXC_TMR0, MSEC(600), 0);
            GPIO_OutSet(&motor_pin);
            TMR_Delay(MXC_TMR0, MSEC(30), 0);
            GPIO_OutClr(&motor_pin);
            TMR_Delay(MXC_TMR0, MSEC(200), 0);
    
    #endif
    #if 0
            LED_Off(0);
            TMR_Delay(MXC_TMR0, MSEC(500), 0);
            LED_On(0);
            TMR_Delay(MXC_TMR0, MSEC(500), 0);
    #endif
    #if 0
            TMR_Delay(MXC_TMR0, MSEC(1000), 0);
            printf("count = %d\n", count++);
    #endif
        }
    }