SRD Standelone programmation box: CR95UartMapper.h File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Enumerations | Functions
CR95UartMapper.h File Reference

Headerfile for Uart mapping on external/internal CR95. More...

`#include "Uart0.h"`
`#include "Uart2.h"`
`#include "Watchdog.h"`
Include dependency graph for CR95UartMapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | CR95UARTMAPPER_EXTERNAL_CO_SHIFT (20U)
| Define the IO mask and shift used the CR95HF Uart Mapper. More...
#define | CR95UARTMAPPER_EXTERNAL_CO_MASK (1<<CR95UARTMAPPER_EXTERNAL_CO_SHIFT)
| Define the IO mask and shift used the CR95HF Uart Mapper. More...

## Enumerations

enum | tCR95UartSelect { CR95_SELECT_INTERNAL = 0, CR95_SELECT_EXTERNAL = 1 }
| Define the antenna ID. More...
enum | tCR95ExternalConnexion { CR95_EXT_CONNECTED = 1, CR95_EXT_UNCONNECTED = 0 }
| Define constant used to detect the connection/deconneciton of the external antenna. More...

## Functions

void | CR95SelectDevice (tCR95UartSelect device)
| Select the antenna used to communicate with the SRD. More...
tCR95ExternalConnexion | CR95ExtGetConnectionState (void)
| Return the connection state of the CR95HF module. More...
void | CR95UartResetReceiver (void)
| Reset the CR95HF Uart interface. More...
tUartCtrl * | CR95UartGetUartStructCtrl (void)
| Return the structure control of the CR95HF uart. More...
void | CR95UartInit (unsigned long baudrate)
| CR95HF Uart interface. More...
void | CR95UartEnableTransmitter (void)
| CR95HF Uart interface. More...
void | CR95UartDisableTransmitter (void)
| CR95HF Uart interface. More...
void | CR95UartEnableReceiver (void)
| CR95HF Uart interface. More...
void | CR95UartDisableReceiver (void)
| CR95HF Uart interface. More...
void | CR95UartClearAllErrorFlag (void)
| CR95HF Uart interface. More...
void | CR95UartSendData (char *data, unsigned short dataLength)
| CR95HF Uart interface. More...
void | CR95UartSendString (char *string)
| CR95HF Uart interface. More...
char | CR95UartReadChar (void)
| CR95HF Uart interface. More...

## Detailed Description

Headerfile for Uart mapping on external/internal CR95.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  20/11/2014

Version
  1.0

All Right Reserved.

Definition in file CR95UartMapper.h.

## Macro Definition Documentation

#define CR95UARTMAPPER_EXTERNAL_CO_MASK (1<<CR95UARTMAPPER_EXTERNAL_CO_SHIFT)

Define the IO mask and shift used the CR95HF Uart Mapper.

Definition at line 37 of file CR95UartMapper.h.

Referenced by CR95UartInit().

#define CR95UARTMAPPER_EXTERNAL_CO_SHIFT (20U)

Define the IO mask and shift used the CR95HF Uart Mapper.

Definition at line 36 of file CR95UartMapper.h.

Referenced by CR95UartInit().

## Enumeration Type Documentation

enum tCR95ExternalConnexion

Define constant used to detect the connection/deconneciton of the external antenna.

Enumerator
CR95_EXT_CONNECTED | External antenna is connected
CR95_EXT_UNCONNECTED | External antenna is not connected

Definition at line 65 of file CR95UartMapper.h.

65 {
66 CR95_EXT_CONNECTED = 1, /*!< External antenna is connected */
67 CR95_EXT_UNCONNECTED = 0 /*!< External antenna is not connected */
68 } tCR95ExternalConnexion;
CR95_EXT_CONNECTED
Definition: CR95UartMapper.h:66
CR95_EXT_UNCONNECTED
Definition: CR95UartMapper.h:67
tCR95ExternalConnexion
tCR95ExternalConnexion
Define constant used to detect the connection/deconneciton of the external antenna.
Definition: CR95UartMapper.h:65

enum tCR95UartSelect

Define the antenna ID.

Enumerator
CR95_SELECT_INTERNAL | Internal antenna ID
CR95_SELECT_EXTERNAL | External antenna ID

Definition at line 54 of file CR95UartMapper.h.

54 {
55 CR95_SELECT_INTERNAL = 0, /*!< Internal antenna ID */
56 CR95_SELECT_EXTERNAL = 1 /*!< External antenna ID */
57 } tCR95UartSelect;
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
tCR95UartSelect
tCR95UartSelect
Define the antenna ID.
Definition: CR95UartMapper.h:54
CR95_SELECT_EXTERNAL
Definition: CR95UartMapper.h:56

## Function Documentation

tCR95ExternalConnexion CR95ExtGetConnectionState | ( | void |  | ) |

Return the connection state of the CR95HF module.

Returns
  (tCR95ExternalConnexion) : Connection state.

Definition at line 174 of file CR95UartMapper.c.

Referenced by RFIDBridgeStateMachine(), RFIDManager(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

174 {
175 /*=== set IO for external CR95 detection ===*/
176 SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK;
177 PTD->PDDR &= ~GPIO_PDDR_PDD(1<<6); //As input
178 PORTD->PCR[6] = PORT_PCR_MUX(0x01); //Switch on IO mode
179 unsigned char countDown = 10;
180 while(countDown--);
181 tCR95ExternalConnexion state = (PTD->PDIR >> 6) & 0x00000001;
182
183 PORTD->PCR[6] &= ~PORT_PCR_MUX_MASK; //Switchback on Uart TX mode
184 PORTD->PCR[6] |= PORT_PCR_MUX(3);
185 return state;
186 }
tCR95ExternalConnexion
tCR95ExternalConnexion
Define constant used to detect the connection/deconneciton of the external antenna.
Definition: CR95UartMapper.h:65

Here is the caller graph for this function:

void CR95SelectDevice | ( | tCR95UartSelect | device | ) |

Select the antenna used to communicate with the SRD.

Parameters

  [in] | device | (tCR95UartSelect) : Select the CR95HF interface (internal or external).

Definition at line 79 of file CR95UartMapper.c.

References CR95DeviceSelected.

Referenced by RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDIntLpmStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

79 {
80 CR95DeviceSelected = device;
81 }
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52

Here is the caller graph for this function:

void CR95UartClearAllErrorFlag | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 124 of file CR95UartMapper.c.

References UART0ClearAllErrorFlag, and UART2ClearAllErrorFlag.

124 {
125 UART2ClearAllErrorFlag();
126 UART0ClearAllErrorFlag();
127 }
UART2ClearAllErrorFlag
#define UART2ClearAllErrorFlag()
Clear all error flag.
Definition: uart2.h:219
UART0ClearAllErrorFlag
#define UART0ClearAllErrorFlag()
Clear all error flag.
Definition: uart0.h:221

void CR95UartDisableReceiver | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 119 of file CR95UartMapper.c.

References UART0DisableReceiver, and UART2DisableReceiver.

Referenced by CR95HFHibernateStateMachine(), CR95HFWriteCommand(), RFIDBridgeStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

119 {
120 UART2DisableReceiver();
121 UART0DisableReceiver();
122 }
UART0DisableReceiver
#define UART0DisableReceiver()
Enable / Disable receiver and its interrupt.
Definition: uart0.h:212
UART2DisableReceiver
#define UART2DisableReceiver()
Enable / Disable receiver and its interrupt.
Definition: uart2.h:210

Here is the caller graph for this function:

void CR95UartDisableTransmitter | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 105 of file CR95UartMapper.c.

References UART0DisableTransmitter, UART0DisableTransmitterInterrupt, and UART2DisableTransmitter.

105 {
106 UART2DisableTransmitter();
107 UART0DisableTransmitter();
108 UART0DisableTransmitterInterrupt();
109 }
UART0DisableTransmitterInterrupt
#define UART0DisableTransmitterInterrupt()
Enable / Disable transmitter and its interrupt.
Definition: uart0.h:203
UART2DisableTransmitter
#define UART2DisableTransmitter()
Enable / Disable transmitter and its interrupt.
Definition: uart2.h:201
UART0DisableTransmitter
#define UART0DisableTransmitter()
Enable / Disable transmitter and its interrupt.
Definition: uart0.h:201

void CR95UartEnableReceiver | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 111 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, UART0EnableReceiver, and UART2EnableReceiver.

Referenced by CR95HFWriteCommand().

111 {
112 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
113 UART2EnableReceiver();
114 } else {
115 UART0EnableReceiver();
116 }
117 }
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
UART2EnableReceiver
#define UART2EnableReceiver()
Enable / Disable receiver and its interrupt.
Definition: uart2.h:209
UART0EnableReceiver
#define UART0EnableReceiver()
Enable / Disable receiver and its interrupt.
Definition: uart0.h:211

Here is the caller graph for this function:

void CR95UartEnableTransmitter | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 96 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, UART0EnableTransmitter, UART0EnableTransmitterInterrupt, and UART2EnableTransmitter.

96 {
97 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
98 UART2EnableTransmitter();
99 } else {
100 UART0EnableTransmitter();
101 UART0EnableTransmitterInterrupt();
102 }
103 }
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
UART0EnableTransmitter
#define UART0EnableTransmitter()
Enable / Disable transmitter and its interrupt.
Definition: uart0.h:200
UART2EnableTransmitter
#define UART2EnableTransmitter()
Enable / Disable transmitter and its interrupt.
Definition: uart2.h:200
UART0EnableTransmitterInterrupt
#define UART0EnableTransmitterInterrupt()
Enable / Disable transmitter and its interrupt.
Definition: uart0.h:202

tUartCtrl* CR95UartGetUartStructCtrl | ( | void |  | ) |

Return the structure control of the CR95HF uart.

Returns
  (tUartCtrl) Uart control structure used by the CR95HF interface.

Definition at line 166 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, Uart0Ctrl, and Uart2Ctrl.

Referenced by CR95HFReadAnswer().

166 {
167 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
168 return &Uart2Ctrl;
169 } else {
170 return &Uart0Ctrl;
171 }
172 }
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
Uart0Ctrl
tUartCtrl Uart0Ctrl
Definition: uart0.c:69
Uart2Ctrl
tUartCtrl Uart2Ctrl
Definition: uart2.c:69

Here is the caller graph for this function:

void CR95UartInit | ( | unsigned long | baudrate | ) |

CR95HF Uart interface.

Definition at line 84 of file CR95UartMapper.c.

References CR95UARTMAPPER_EXTERNAL_CO_MASK, CR95UARTMAPPER_EXTERNAL_CO_SHIFT, Uart0Init(), Uart2Init(), and WatchdogKick().

Referenced by CR95HFInit().

84 {
85 Uart0Init(baudrate);
86 WatchdogKick();
87 Uart2Init(baudrate);
88 WatchdogKick();
89
90 /*=== set IO for external CR95 detection ===*/
91 SIM->SCGC5 |= SIM_SCGC5_PORTE_MASK;
92 PTA->PDDR &= ~GPIO_PDDR_PDD(CR95UARTMAPPER_EXTERNAL_CO_MASK); //As input
93 PORTA->PCR[CR95UARTMAPPER_EXTERNAL_CO_SHIFT] = PORT_PCR_MUX(0x01); //IO config
94 }
Uart2Init
void Uart2Init(unsigned long baudrate)
Initialize this uart.
Definition: uart2.c:149
WatchdogKick
void WatchdogKick(void)
Kick the watchdog to avoid reset after the watchdog have started.
Definition: watchdog.c:86
CR95UARTMAPPER_EXTERNAL_CO_MASK
#define CR95UARTMAPPER_EXTERNAL_CO_MASK
Define the IO mask and shift used the CR95HF Uart Mapper.
Definition: CR95UartMapper.h:37
Uart0Init
void Uart0Init(unsigned long baudrate)
Initialize this uart.
Definition: uart0.c:150
CR95UARTMAPPER_EXTERNAL_CO_SHIFT
#define CR95UARTMAPPER_EXTERNAL_CO_SHIFT
Define the IO mask and shift used the CR95HF Uart Mapper.
Definition: CR95UartMapper.h:36

Here is the call graph for this function:

Here is the caller graph for this function:

char CR95UartReadChar | ( | void |  | ) |

CR95HF Uart interface.

Definition at line 145 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, Uart0ReadChar(), and Uart2ReadChar().

Referenced by CR95HFReadAnswer().

145 {
146 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
147 return Uart2ReadChar();
148 } else {
149 return Uart0ReadChar();
150 }
151 }
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
Uart2ReadChar
char Uart2ReadChar(void)
Definition: uart2.c:246
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
Uart0ReadChar
char Uart0ReadChar(void)
Definition: uart0.c:249

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95UartResetReceiver | ( | void |  | ) |

Reset the CR95HF Uart interface.

Definition at line 153 of file CR95UartMapper.c.

References tUartFlags::bits, tUartFlags::charReceived, tUartCtrl::flags, tUartFifo::lastIn, tUartFifo::lastOut, tUartFifo::nbrChar, tUartCtrl::rx, tUartFlags::stringReceived, Uart0Ctrl, and Uart2Ctrl.

Referenced by CR95HFWriteCommand().

153 {
154 Uart0Ctrl.rx.lastIn = 0;
155 Uart0Ctrl.rx.lastOut = 0;
156 Uart0Ctrl.rx.nbrChar = 0;
157 Uart0Ctrl.flags.bits.charReceived = 0;
158 Uart0Ctrl.flags.bits.stringReceived = 0;
159 Uart2Ctrl.rx.lastIn = 0;
160 Uart2Ctrl.rx.lastOut = 0;
161 Uart2Ctrl.rx.nbrChar = 0;
162 Uart2Ctrl.flags.bits.charReceived = 0;
163 Uart2Ctrl.flags.bits.stringReceived = 0;
164 }
tUartCtrl::rx
tUartFifo rx
Definition: uart_common.h:77
tUartFifo::lastOut
unsigned short lastOut
Definition: uart_common.h:48
tUartFlags::bits
struct tUartFlags::@21 bits
Uart0Ctrl
tUartCtrl Uart0Ctrl
Definition: uart0.c:69
tUartFlags::stringReceived
unsigned char stringReceived
Definition: uart_common.h:61
tUartCtrl::flags
tUartFlags flags
Definition: uart_common.h:79
Uart2Ctrl
tUartCtrl Uart2Ctrl
Definition: uart2.c:69
tUartFifo::lastIn
unsigned short lastIn
Definition: uart_common.h:47
tUartFifo::nbrChar
unsigned short nbrChar
Definition: uart_common.h:49
tUartFlags::charReceived
unsigned char charReceived
Definition: uart_common.h:60

Here is the caller graph for this function:

void CR95UartSendData | ( | char * | data,
|  | unsigned short | dataLength
| ) |  |

CR95HF Uart interface.

Definition at line 129 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, Uart0SendData(), and Uart2SendData().

Referenced by CR95HFWriteCommand(), RFIDBridgeStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

129 {
130 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
131 Uart2SendData(data, dataLength);
132 } else {
133 Uart0SendData(data, dataLength);
134 }
135 }
Uart2SendData
void Uart2SendData(char *data, unsigned short dataLength)
send data other uart.
Definition: uart2.c:194
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
Uart0SendData
void Uart0SendData(char *data, unsigned short dataLength)
send data other uart.
Definition: uart0.c:196
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95UartSendString | ( | char * | string | ) |

CR95HF Uart interface.

Definition at line 137 of file CR95UartMapper.c.

References CR95_SELECT_INTERNAL, CR95DeviceSelected, Uart0SendString(), and Uart2SendString().

137 {
138 if(CR95DeviceSelected == CR95_SELECT_INTERNAL) {
139 Uart2SendString(string);
140 } else {
141 Uart0SendString(string);
142 }
143 }
Uart0SendString
void Uart0SendString(char *string)
send ASCII string other uart.
Definition: uart0.c:224
CR95DeviceSelected
tCR95UartSelect CR95DeviceSelected
Definition: CR95UartMapper.c:52
Uart2SendString
void Uart2SendString(char *string)
send ASCII string other uart.
Definition: uart2.c:221
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55

Here is the call graph for this function: