-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIQRFPort.h
124 lines (102 loc) · 2.79 KB
/
IQRFPort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* @file IQRF SPI support library
* @author Dušan Machút <[email protected]>
* @author Rostislav Špinar <[email protected]>
* @author Roman Ondráček <[email protected]>
* @version 3.1.1
*
* Copyright 2015-2018 IQRF Tech s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IQRF_PORTS_H
#define IQRF_PORTS_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
// Pins
#if !defined(TR_PWRCTRL_PIN)
#define TR_PWRCTRL_PIN 9 //!< TR power control pin
#endif
#if !defined(TR_SS_PIN)
#define TR_SS_PIN 8 //!< SPI SS pin
#endif
#define TR_MOSI_PIN PIN_SPI_MOSI //!< SPI MOSI pin
#define TR_MISO_PIN PIN_SPI_MISO //!< SPI MISO pin
#define TR_SCK_PIN PIN_SPI_SCK //!< SPI SCK pin
#define TICKS_IN_SECOND 1000
#define iqrfDelayMs(T) delay(T)
#define iqrfGetSysTick() millis()
typedef struct {
uint16_t FileByteCnt; // size of code file on SD card
uint16_t FileSize; // size of code file on SD card
uint8_t FileType; // file type (HEX / IQRF)
} IQRF_PGM_FILE_INFO;
typedef void (*T_IQRF_RX_HANDLER)(uint8_t *DataBuffer, uint8_t DataSize);
typedef struct {
volatile uint8_t Status;
uint8_t SuspendFlag;
uint8_t TRmoduleSelected;
uint8_t FastSPI;
uint8_t TimeCnt;
T_IQRF_RX_HANDLER IqrfRxHandler;
} T_IQRF_CONTROL;
extern IQRF_PGM_FILE_INFO CodeFileInfo;
extern T_IQRF_CONTROL IqrfControl;
/**
* initialize IQRF SPI kernel timing
*/
void iqrfKernelTimingInit(void);
/**
* switch IQRF SPI kernel timing to fast mode
*/
void iqrfKernelTimingFastMode(void);
/**
* turn OFF power supply of TR module
*/
void iqrfTrPowerOff(void);
/**
* turn ON power supply of TR module
*/
void iqrfTrPowerOn(void);
/**
* switch TR module to programming mode
*/
void iqrfTrEnterPgmMode(void);
/**
* Deselect TR module
*/
void iqrfDeselectTRmodule(void);
/**
* Send byte over SPI
*
* @param Tx_Byte to send
* @return Received Rx_Byte
*
*/
uint8_t iqrfSendSpiByte(uint8_t Tx_Byte);
/**
* Read byte from code file
*
* @param - none
* @return - byte from firmware file or 0 = end of file
*
*/
uint8_t iqrfReadByteFromFile(void);
#if defined(__cplusplus)
}
#endif
#endif