main.c 2.53 KB
Newer Older
1
/*******************************************************************************
2
 * License: TBD
3
4
5
 ******************************************************************************/

/***** Includes *****/
6
#include "pmic.h"
schneider's avatar
schneider committed
7
#include "leds.h"
8
9
#include "card10.h"

schneider's avatar
schneider committed
10
11
#include "GUI_Paint.h"

12
13
#include "tmr_utils.h"

14
15
#include <stdio.h>
#include <stdint.h>
schneider's avatar
schneider committed
16
#include <string.h>
schneider's avatar
schneider committed
17
#include <Heart.h>
18
19
20
21

/***** Definitions *****/

/***** Globals *****/
22
static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
23

schneider's avatar
schneider committed
24
25
26
27
28
29
30
31
32
33
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;
}

34
35
36
37
int main(void)
{
    int count = 0;

38
    card10_init();
schneider's avatar
schneider committed
39
40
41
    //card10_diag();

    GPIO_Config(&motor_pin);
schneider's avatar
schneider committed
42

schneider's avatar
schneider committed
43
    Paint_DrawImage(Heart, 0, 0, 160, 80);
44
    LCD_Update();
schneider's avatar
schneider committed
45

46
47
48
49
    for(int i=0; i<11; i++) {
        leds_set_dim(i, 1);
    }

schneider's avatar
schneider committed
50
    int h = 0;
schneider's avatar
schneider committed
51
52
    Core1_Start();

53
    while (1) {
54

schneider's avatar
schneider committed
55
#if 1
56
57
58
59
60
61
62
63
        #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.);
            }
        }
schneider's avatar
schneider committed
64
65
66
67
        //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);
68

schneider's avatar
schneider committed
69
70
71
72
        leds_update();
        TMR_Delay(MXC_TMR0, MSEC(10), 0);
        h++;
#endif
schneider's avatar
schneider committed
73
#if 0
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
        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);
92
93
94
95
        //TMR_Delay(MXC_TMR0, MSEC(200), 0);
#endif
#if 0
        //TMR_Delay(MXC_TMR0, MSEC(600), 0);
schneider's avatar
schneider committed
96
        GPIO_OutSet(&motor_pin);
97
        TMR_Delay(MXC_TMR0, MSEC(30), 0);
schneider's avatar
schneider committed
98
        GPIO_OutClr(&motor_pin);
99
        TMR_Delay(MXC_TMR0, MSEC(200), 0);
schneider's avatar
schneider committed
100

101
102
103
104
105
106
107
#endif
#if 0
        LED_Off(0);
        TMR_Delay(MXC_TMR0, MSEC(500), 0);
        LED_On(0);
        TMR_Delay(MXC_TMR0, MSEC(500), 0);
#endif
schneider's avatar
schneider committed
108
#if 0
109
        TMR_Delay(MXC_TMR0, MSEC(1000), 0);
110
        printf("count = %d\n", count++);
schneider's avatar
schneider committed
111
#endif
112
113
    }
}