Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_Boards.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: 2 Feb., 2017
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 *
7 * NOTE 1: This file is written in C so that it can be used in the bootloader as well.
8 *
9 * NOTE 2: If you add a new BOARD, also update the function get_hardware_version in cs_HardwareVersions.h.
10 *
11 * NOTE 3: If you add a new BOARD that has a different pin layout or other board changes, define a new function and
12 * add it as a switch case to the configure_board function
13 *
14 * NOTE 4: This is the only place where the versions are maintained. There is a separate cmake module that knows
15 * how to extract the BOARD_VERSION from this header file. It uses a particular regular expression. If you add
16 * weird define statements, this module might choke on that.
17 */
18
19#pragma once
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
27#include <stdbool.h>
28#include <stdint.h>
29
36// Nordic dev board, but with some hardware bugs.
37#define PCA10036 40
38// Nordic dev board in active use.
39#define PCA10040 41
40// Nordic dev board for the nRF52833
41#define PCA10100 42
42// Nordic dev board for the nRF52840
43#define PCA10056 43
44
45// Rectangular beacons from China.
46#define GUIDESTONE 100
47
48// Crownstone USB dongle
49#define CS_USB_DONGLE 200
50
51// CROWNSTONE BUILTINS
52
53// Prototype builtin. Not in production.
54#define ACR01B1A 1000
55// Prototype builtin. Not in production.
56#define ACR01B1B 1001
57// Prototype builtin. Not in production.
58#define ACR01B1C 1002
59#define ACR01B1D 1003 // released
60#define ACR01B1E 1004 // same as ACR01B1D, but with patch
61#define ACR01B10B 1007 // Builtin One v20
62#define ACR01B10D 1008 // Builtin One v25
63
64#define ACR01B13B 1009 // Builtin Two development version
65#define ACR01B15A 1010 // Builtin Two (V3-ACR01B15A-rev7)
66
67// CROWNSTONE PLUGS
68
69// Prototype plug.
70#define ACR01B2A 1500
71
72// Prototype plug. Replace caps before and after LDO with electrolytic caps due to DC bias.
73#define ACR01B2B 1501
74
75// Production release plug. Replace primary supply registor with MELF type and increase value to 100 Ohm.
76#define ACR01B2C 1502
77
78// Prototype plug. Remove MELF. Add compensation cap. Remove C7. Add pull-down resistor to LGBT driver input.
79// Move thermal fuse to cover both power paths. Alter offset and gain of power measurement service. Add measurement
80// offset to ADC.
81#define ACR01B2E 1503
82
83// Production release plug. Schematic change. Change power measurement resistor values.
84#define ACR01B2G 1504
85
86// Prototype Crownstone Plug One (first prototype of second edition of the plug)
87#define ACR01B11A 1505
88
89// CROWNSTONE OUTLETS
90
91// Prototype outlet
92#define CR01R02v4 1100
93
94#define PIN_NONE 0xFF
95
101 GAIN_SINGLE = 0, // If there is only a single gain, use the low gain.
102};
103
110};
111
124};
125
127 LED0 = 0,
128 LED1 = 1,
129 LED2 = 2,
130 LED3 = 3,
134};
135
140};
141
156uint8_t GpioToAinOnChipset(uint8_t gpio, uint8_t chipset);
157
158// For now mapping is always the same, so this simplified function can be used.
159uint8_t GpioToAin(uint8_t gpio);
160
161// Maps P1.01 to uint8 pin number.
162uint8_t GetGpioPin(uint8_t major, uint8_t minor);
163
169typedef struct {
172
174 uint8_t pinDimmer;
175
178
181
183 uint8_t pinRelayOn;
184
186 uint8_t pinRelayOff;
187
189 uint8_t pinAinCurrent[GAIN_COUNT];
190
192 uint8_t pinAinVoltage[GAIN_COUNT];
193
195 uint8_t pinAinVoltageAfterLoad[GAIN_COUNT];
196
199
202
204 uint8_t pinAinEarth;
205
208
211
213 uint8_t pinRx;
214
216 uint8_t pinTx;
217
219 uint8_t pinGpio[GPIO_INDEX_COUNT];
220
222 uint8_t pinButton[BUTTON_COUNT];
223
225 uint8_t pinLed[LED_COUNT];
226
228 struct __attribute__((__packed__)) {
230 uint8_t cs;
232 uint8_t clk;
234 uint8_t dio[4];
235 } pinFlash;
236
238 struct __attribute__((__packed__)) {
241
243 bool enableUart : 1;
244
247 bool enableLeds : 1;
248
250 bool ledInverted : 1;
251
254
256 bool usesNfcPins : 1;
257
260
264
267
270 } flags;
271
276 uint8_t deviceType;
277
282 float voltageMultiplier[GAIN_COUNT];
283
288 float voltageAfterLoadMultiplier[GAIN_COUNT];
289
294 float currentMultiplier[GAIN_COUNT];
295
297 int32_t voltageOffset[GAIN_COUNT];
298
300 int32_t voltageAfterLoadOffset[GAIN_COUNT];
301
303 int32_t currentOffset[GAIN_COUNT];
304
307
314
320
327
330
333
346
353 uint32_t scanWindowUs;
354
359
361
365void init(boards_config_t* config);
366
378
381
382#ifdef __cplusplus
383}
384#endif
ButtonIndex
Definition: cs_Boards.h:104
@ BUTTON0
Definition: cs_Boards.h:105
@ BUTTON_COUNT
Definition: cs_Boards.h:109
@ BUTTON1
Definition: cs_Boards.h:106
@ BUTTON2
Definition: cs_Boards.h:107
@ BUTTON3
Definition: cs_Boards.h:108
GpioIndex
Definition: cs_Boards.h:112
@ GPIO_INDEX1
Definition: cs_Boards.h:114
@ GPIO_INDEX6
Definition: cs_Boards.h:119
@ GPIO_INDEX9
Definition: cs_Boards.h:122
@ GPIO_INDEX5
Definition: cs_Boards.h:118
@ GPIO_INDEX2
Definition: cs_Boards.h:115
@ GPIO_INDEX7
Definition: cs_Boards.h:120
@ GPIO_INDEX0
Definition: cs_Boards.h:113
@ GPIO_INDEX_COUNT
Definition: cs_Boards.h:123
@ GPIO_INDEX3
Definition: cs_Boards.h:116
@ GPIO_INDEX4
Definition: cs_Boards.h:117
@ GPIO_INDEX8
Definition: cs_Boards.h:121
uint8_t GpioToAin(uint8_t gpio)
void init(boards_config_t *config)
initializes a board config to default values.
uint8_t GetGpioPin(uint8_t major, uint8_t minor)
uint8_t GpioToAinOnChipset(uint8_t gpio, uint8_t chipset)
Maps GPIO pins to AIN pins.
LedIndex
Definition: cs_Boards.h:126
@ LED_GREEN
Definition: cs_Boards.h:133
@ LED_COUNT
Definition: cs_Boards.h:131
@ LED3
Definition: cs_Boards.h:130
@ LED2
Definition: cs_Boards.h:129
@ LED0
Definition: cs_Boards.h:127
@ LED_RED
Definition: cs_Boards.h:132
@ LED1
Definition: cs_Boards.h:128
cs_ret_code_t configure_board(boards_config_t *p_config)
Configure board.
cs_ret_code_t configure_board_from_uicr(const cs_uicr_data_t *uicrData, boards_config_t *config)
GainIndex
Definition: cs_Boards.h:96
@ GAIN_LOW
Definition: cs_Boards.h:97
@ GAIN_COUNT
Definition: cs_Boards.h:100
@ GAIN_MIDDLE
Definition: cs_Boards.h:98
@ GAIN_SINGLE
Definition: cs_Boards.h:101
@ GAIN_HIGH
Definition: cs_Boards.h:99
Chipset
Definition: cs_Boards.h:136
@ CHIPSET_NRF52833
Definition: cs_Boards.h:138
@ CHIPSET_NRF52840
Definition: cs_Boards.h:139
@ CHIPSET_NRF52832
Definition: cs_Boards.h:137
cs_ret_code_t configure_board_from_hardware_board(uint32_t hardwareBoard, boards_config_t *config)
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
Board configuration.
Definition: cs_Boards.h:169
uint8_t pinDimmer
GPIO pin to control the IGBTs.
Definition: cs_Boards.h:174
int32_t powerOffsetMilliWatt
Measured power when there is no load (mW).
Definition: cs_Boards.h:306
int8_t minTxPower
The minimum radio transmission power to be used.
Definition: cs_Boards.h:326
bool enableUart
True if the board should have UART enabled by default.
Definition: cs_Boards.h:243
uint8_t clk
Clock pin.
Definition: cs_Boards.h:232
uint8_t pinAinDimmerTemp
Analog input pin to read the dimmer temperature.
Definition: cs_Boards.h:201
uint8_t pinVoltageZeroCrossing
GPIO pin to get zero-crossing information for voltage.
Definition: cs_Boards.h:210
bool ledInverted
True if LED is off when GPIO is set high.
Definition: cs_Boards.h:250
uint32_t scanIntervalUs
Scan interval in μs.
Definition: cs_Boards.h:345
bool canTryDimmingOnBoot
True if the Crownstone can try dimming at boot, because it has an accurate enough power measurement,...
Definition: cs_Boards.h:263
uint8_t pinRelayDebug
GPIO to debug the relay: turns on when relay is turned on, and vice versa. Inverted when LEDs are inv...
Definition: cs_Boards.h:180
float pwmTempVoltageThresholdDown
Voltage of PWM thermometer at which the dimmer is cool enough again.
Definition: cs_Boards.h:332
bool dimmerOnWhenPinsFloat
True if the dimmer can be on when the pins are floating (during boot).
Definition: cs_Boards.h:269
uint32_t currentAdcRangeMilliVolt
Range in mV to be used for the current pin.
Definition: cs_Boards.h:319
uint32_t scanWindowUs
Scan window in μs.
Definition: cs_Boards.h:353
int8_t tapToToggleDefaultRssiThreshold
Default RSSI threshold, above which tap to toggle will trigger.
Definition: cs_Boards.h:358
uint8_t pinTx
GPIO pin to send UART.
Definition: cs_Boards.h:216
uint32_t hardwareBoard
The hardware board type (number).
Definition: cs_Boards.h:171
uint8_t pinAinEarth
Analog input pin to measure EARTH.
Definition: cs_Boards.h:204
bool dimmerInverted
True if the dimmer is inverted (setting gpio high turns dimmer off).
Definition: cs_Boards.h:240
bool enableLeds
True if the board has LEDs that should be enabled by default.
Definition: cs_Boards.h:247
uint8_t deviceType
Device type, e.g.
Definition: cs_Boards.h:276
bool dimmerTempInverted
True if the temperature sensor of the dimmer is inverted (NTC).
Definition: cs_Boards.h:253
bool canDimOnWarmBoot
True if the Crownstone can dim immediately after a warm boot.
Definition: cs_Boards.h:266
float pwmTempVoltageThreshold
Voltage of PWM thermometer at which the dimmer is too hot.
Definition: cs_Boards.h:329
uint8_t pinRelayOn
GPIO pin to switch the relay on.
Definition: cs_Boards.h:183
uint8_t pinRelayOff
GPIO pin to switch the relay off.
Definition: cs_Boards.h:186
bool usesNfcPins
True if the NFC pins (p0.09 and p0.10) are used as GPIO.
Definition: cs_Boards.h:256
uint8_t pinAinZeroRef
Analog input pin to read 'zero' / offset (to be used for both current and voltage measurements).
Definition: cs_Boards.h:198
bool hasAccuratePowerMeasurement
True if the Crownstone has a more accurate power measurement.
Definition: cs_Boards.h:259
uint32_t voltageAdcRangeMilliVolt
Range in mV to be used for the voltage pin.
Definition: cs_Boards.h:313
uint8_t cs
Chip select pin.
Definition: cs_Boards.h:230
uint8_t pinEnableDimmer
GPIO pin to enable the IGBT circuit.
Definition: cs_Boards.h:177
uint8_t pinRx
GPIO pin to receive UART.
Definition: cs_Boards.h:213
uint8_t pinCurrentZeroCrossing
GPIO pin to get zero-crossing information for current.
Definition: cs_Boards.h:207
Struct with all the Crownstone fields in UICR.
Definition: cs_UicrPacket.h:20