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