Subversion Repositories NaviCtrl

Rev

Rev 264 | Rev 718 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 264 Rev 680
1
#include "91x_lib.h"
1
#include "91x_lib.h"
2
#include "led.h"
2
#include "led.h"
3
 
3
 
4
u8 Version_HW = 0;
4
u8 Version_HW = 0;
5
u8 Led_Grn_Inv = 0;
5
u8 Led_Grn_Inv = 0;
6
u8 Led_Red_Inv = 0;
6
u8 Led_Red_Inv = 0;
7
 
7
 
8
void Led_Init(void)
8
void Led_Init(void)
9
{
9
{
10
        u8 p5;
10
        u8 p5;
11
        u16 i;
11
        u16 i;
12
        GPIO_InitTypeDef GPIO_InitStructure;
12
        GPIO_InitTypeDef GPIO_InitStructure;
13
 
13
 
14
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock
14
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock
15
       
15
       
16
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/
16
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/
17
        GPIO_StructInit(&GPIO_InitStructure);
17
        GPIO_StructInit(&GPIO_InitStructure);
18
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
18
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
19
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
19
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
20
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull ;
20
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull ;
21
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
21
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
22
        GPIO_Init(GPIO5, &GPIO_InitStructure);
22
        GPIO_Init(GPIO5, &GPIO_InitStructure);
23
        // set both ports low
23
        // set both ports low
24
        GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET);
24
        GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET);
25
        GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET);
25
        GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET);
26
 
26
 
27
        // Check LED Polarity
27
        // Check LED Polarity
28
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as input*/
28
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as input*/
29
        GPIO_StructInit(&GPIO_InitStructure);
29
        GPIO_StructInit(&GPIO_InitStructure);
30
        GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
30
        GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
31
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
31
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
32
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull;
32
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull;
33
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
33
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
34
        GPIO_Init(GPIO5, &GPIO_InitStructure);
34
        GPIO_Init(GPIO5, &GPIO_InitStructure);
35
   
35
   
36
        // get polarity of LED ports
36
        // get polarity of LED ports
37
        for(i=0;i<500;i++) p5 = GPIO_Read(GPIO5);
37
        for(i=0;i<500;i++) p5 = GPIO_Read(GPIO5);
38
        Led_Grn_Inv = 0x01 & (p5>>6);
38
        Led_Grn_Inv = 0x01 & (p5>>6);
39
        Led_Red_Inv = 0x01 & (p5>>7);
39
        Led_Red_Inv = 0x01 & (p5>>7);
40
 
40
 
41
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/
41
        /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/
42
        GPIO_StructInit(&GPIO_InitStructure);
42
        GPIO_StructInit(&GPIO_InitStructure);
43
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
43
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
44
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
44
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_6 | GPIO_Pin_7;
45
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull ;
45
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull ;
46
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
46
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
47
        GPIO_Init(GPIO5, &GPIO_InitStructure);
47
        GPIO_Init(GPIO5, &GPIO_InitStructure);
48
 
48
 
49
        LED_GRN_OFF;
49
        LED_GRN_OFF;
50
        LED_RED_OFF;
50
        LED_RED_OFF;
51
 
51
 
52
        if(Led_Grn_Inv)
52
        if(Led_Grn_Inv)
53
        {
53
        {
54
                if(Led_Red_Inv) Version_HW = 30; //future use
54
                if(Led_Red_Inv) Version_HW = 30; //future use
55
                else                    Version_HW = 20; // NC 2.0      
55
                else                    Version_HW = 20; // NC 2.0      
56
        }
56
        }
57
        else
57
        else
58
        {
58
        {
59
                if(Led_Red_Inv) Version_HW = 40; // future use
59
                if(Led_Red_Inv) Version_HW = 40; // future use
60
                else                    Version_HW = 11; // NC 1.x
60
                else                    Version_HW = 11; // NC 1.x
61
        }
61
        }
-
 
62
 
-
 
63
/*
-
 
64
// External Inputs P6.3 & P6.4 & P6.5  
-
 
65
        GPIO_StructInit(&GPIO_InitStructure);
-
 
66
        GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
-
 
67
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
-
 
68
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull;
-
 
69
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
-
 
70
        GPIO_Init(GPIO6, &GPIO_InitStructure);
-
 
71
 
-
 
72
        // set port pin 6.2 to output
-
 
73
        GPIO_StructInit(&GPIO_InitStructure);
-
 
74
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
-
 
75
        GPIO_InitStructure.GPIO_Pin =           GPIO_Pin_2;
-
 
76
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull;
-
 
77
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
-
 
78
        GPIO_Init(GPIO6, &GPIO_InitStructure);
-
 
79
GPIO_WriteBit(GPIO6, GPIO_Pin_2, Bit_SET);
62
 
80
*/
63
}
81
}
64
 
82