source: test2.git/Hardware.c@ b6aa0ba

Last change on this file since b6aa0ba was b6aa0ba, checked in by andib <andi.b@…>, 2 years ago

test with more files

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*******************************************************************************
2MODULE : Hardware.c
3 Hardware related functions, detecting hardware type (physical board layout)
4 and revision, manage MAC address, validate application software (as soon as in
5 application flashing is implemented)
6
720101117 AB Initial
820180808 AB Adapted to CAN-Tester
920191219 AB Adapted for JADE EFM32JG1B test
10*******************************************************************************/
11
12// --- Includes ---------------------------------------------------------------
13#define LOGGING_TOKEN HW_LOGGING
14#include "TraceLeUart.h"
15
16#include <efm32.h>
17#include <em_cmu.h>
18#include <em_gpio.h>
19#include <em_usart.h>
20#include <em_timer.h>
21
22#include "types.h"
23#include "Hardware.h"
24
25// --- Pin Definitions --------------------------------------------------------
26/*#define PORT gpioPortB
27#define PORT_BIT 6
28#define TESTPIN_INIT(); { GPIO_PinModeSet(PORT, PORT_BIT, gpioModePushPull, 0);}
29#define TESTPIN( x ); { if ( x ) GPIO->P[PORT].DOUT |= ( 1 << PORT_BIT ); \
30 else GPIO->P[PORT].DOUT &= ~( 1 << PORT_BIT ); }
31*/
32// --- Defines ----------------------------------------------------------------
33
34// --- Typedefs ---------------------------------------------------------------
35
36// --- PUBLIC Variables -------------------------------------------------------
37
38// --- Variables --------------------------------------------------------------
39static BYTE bHwType = 0;
40static BYTE bHwVersion = 0;
41static BYTE bHwRevision = 0;
42
43// --- Macros -----------------------------------------------------------------
44
45// --- Functionprototypes -----------------------------------------------------
46
47;
48// --- Code -------------------------------------------------------------------
49/******************************************************************************
50void HwInit (void)
51 Initialize module Hardware part 1
52******************************************************************************/
53void HwInit (void)
54 {
55 TRACE("HW: init");
56
57 }
58
59/******************************************************************************
60int HwGetType(void);
61 Returns hardware type previously read from config pins
62******************************************************************************/
63int HwGetType(void)
64 {
65 return bHwType;
66 }
67
68
69/******************************************************************************
70int HwGetVersion(void);
71 Returns hardware version previously read from config pins
72******************************************************************************/
73int HwGetVersion(void)
74 {
75 return bHwVersion;
76 }
77
78/******************************************************************************
79int HwGetRevision(void);
80 Returns hardware revision
81 Currently not defined so 0 is returned
82******************************************************************************/
83int HwGetRevision(void)
84 {
85 return bHwRevision;
86 }
87
88/******************************************************************************
89void HwTraceHwInfo(void)
90******************************************************************************/
91void HwTraceInfo(void)
92 {
93 TRACE ("HW: switch 0x%02X", HwGetType() );
94 }
95
96/******************************************************************************
97void _delay_us (int us)
98 Delays specified number of micro seconds. Valid for EFM32G880 & EFM32GG380
99 running at standard HFRCO frequency (6.6MHz)
100******************************************************************************/
101
102// have to be at the end of source file cause overrides optimization level
103
104// min. is about 4us (including pin H/L before/after)
105// 10 --> 12us
106// 6000 --> 5ms
107
108#pragma GCC optimize ("-O0")
109
110void _delay_us( int us )
111 {
112
113// TESTPIN(1);
114#ifdef HW_MASTER
115 // master runs with 28MHz
116 us <<= 1;
117#endif
118 while (us--);
119// TESTPIN(0);
120 }
121
122
123
Note: See TracBrowser for help on using the repository browser.