Subversion Repositories NaviCtrl

Rev

Rev 41 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 41 Rev 264
Line 1... Line 1...
1
#include "91x_lib.h"
1
#include "91x_lib.h"
2
#include "led.h"
2
#include "led.h"
Line -... Line 3...
-
 
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;
Line 6... Line 12...
6
    GPIO_InitTypeDef GPIO_InitStructure;
12
        GPIO_InitTypeDef GPIO_InitStructure;
7
 
-
 
8
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock    
-
 
9
         
-
 
10
        /*Configure LED_GRN at pin GPIO5.6 and LED_ROT at pin GPIO5.7*/
-
 
11
        GPIO_StructInit(&GPIO_InitStructure);
-
 
12
    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
-
 
13
    GPIO_InitStructure.GPIO_Pin =               GPIO_Pin_6 | GPIO_Pin_7;
-
 
14
    GPIO_InitStructure.GPIO_Type =              GPIO_Type_PushPull ;
-
 
Line -... Line 13...
-
 
13
 
15
    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1  ;
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;
16
    GPIO_Init(GPIO5, &GPIO_InitStructure);
20
        GPIO_InitStructure.GPIO_Type =          GPIO_Type_PushPull ;
17
       
-
 
-
 
21
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
-
 
22
        GPIO_Init(GPIO5, &GPIO_InitStructure);
Line -... Line 23...
-
 
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
   
Line -... Line 36...
-
 
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 ;
Line -... Line 46...
-
 
46
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
-
 
47
        GPIO_Init(GPIO5, &GPIO_InitStructure);
-
 
48
 
-
 
49
        LED_GRN_OFF;
-
 
50
        LED_RED_OFF;
-
 
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