Rev 41 | Rev 680 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 41 | Rev 264 | ||
---|---|---|---|
1 | #include "91x_lib.h" |
1 | #include "91x_lib.h" |
2 | #include "led.h" |
2 | #include "led.h" |
- | 3 | ||
- | 4 | u8 Version_HW = 0; |
|
- | 5 | u8 Led_Grn_Inv = 0; |
|
- | 6 | u8 Led_Red_Inv = 0; |
|
3 | 7 | ||
4 | void Led_Init(void) |
8 | void Led_Init(void) |
- | 9 | { |
|
- | 10 | u8 p5; |
|
5 | { |
11 | u16 i; |
6 | GPIO_InitTypeDef GPIO_InitStructure; |
12 | GPIO_InitTypeDef GPIO_InitStructure; |
7 | 13 | ||
8 | SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
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*/ |
|
- | 17 | GPIO_StructInit(&GPIO_InitStructure); |
|
- | 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 | ||
9 | 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 | ||
10 | /*Configure LED_GRN at pin GPIO5.6 and LED_ROT at pin GPIO5.7*/ |
41 | /*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/ |
11 | GPIO_StructInit(&GPIO_InitStructure); |
42 | GPIO_StructInit(&GPIO_InitStructure); |
12 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
43 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
13 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
44 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
14 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
45 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
15 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1 ; |
46 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; |
16 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
47 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
17 | 48 | ||
18 | LED_GRN_OFF; |
49 | LED_GRN_OFF; |
19 | LED_RED_OFF; |
50 | LED_RED_OFF; |
20 | } |
- | |
21 | - | ||
- | 51 | ||
- | 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 | } |
|
22 | 62 | ||
23 | 63 | } |
|
24 | 64 |