Rev 264 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
41 | ingob | 1 | #include "91x_lib.h" |
2 | #include "led.h" |
||
3 | |||
264 | killagreg | 4 | u8 Version_HW = 0; |
5 | u8 Led_Grn_Inv = 0; |
||
6 | u8 Led_Red_Inv = 0; |
||
7 | |||
41 | ingob | 8 | void Led_Init(void) |
9 | { |
||
264 | killagreg | 10 | u8 p5; |
11 | u16 i; |
||
12 | GPIO_InitTypeDef GPIO_InitStructure; |
||
41 | ingob | 13 | |
264 | killagreg | 14 | SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
15 | |||
16 | /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/ |
||
41 | ingob | 17 | GPIO_StructInit(&GPIO_InitStructure); |
264 | killagreg | 18 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
19 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
||
20 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
||
21 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; |
||
22 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
||
23 | // set both ports low |
||
24 | GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET); |
||
25 | GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET); |
||
26 | |||
27 | // Check LED Polarity |
||
28 | /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as input*/ |
||
29 | GPIO_StructInit(&GPIO_InitStructure); |
||
30 | GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
||
31 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
||
32 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
||
33 | GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
||
34 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
||
35 | |||
36 | // get polarity of LED ports |
||
37 | for(i=0;i<500;i++) p5 = GPIO_Read(GPIO5); |
||
38 | Led_Grn_Inv = 0x01 & (p5>>6); |
||
39 | Led_Red_Inv = 0x01 & (p5>>7); |
||
40 | |||
41 | /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/ |
||
42 | GPIO_StructInit(&GPIO_InitStructure); |
||
43 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
||
44 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
||
45 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
||
46 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; |
||
47 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
||
48 | |||
41 | ingob | 49 | LED_GRN_OFF; |
264 | killagreg | 50 | LED_RED_OFF; |
41 | ingob | 51 | |
264 | killagreg | 52 | if(Led_Grn_Inv) |
53 | { |
||
54 | if(Led_Red_Inv) Version_HW = 30; //future use |
||
55 | else Version_HW = 20; // NC 2.0 |
||
56 | } |
||
57 | else |
||
58 | { |
||
59 | if(Led_Red_Inv) Version_HW = 40; // future use |
||
60 | else Version_HW = 11; // NC 1.x |
||
61 | } |
||
41 | ingob | 62 | |
264 | killagreg | 63 | } |