Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cs_HardwareVersions.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <cfg/cs_AutoConfig.h>
10#include <cfg/cs_Boards.h>
11#include <drivers/cs_Uicr.h>
13#include <stdio.h>
14
15//#ifdef __cplusplus
16// extern "C" {
17//#endif
18//
19//#include "nrf52.h"
20//#include "string.h"
21//
22//#ifdef __cplusplus
23//}
24//#endif
25
26/*
27 ----------------------
28 | GENERAL | PCB |
29 | PRODUCT | VERSION |
30 | INFO | |
31 ----------------------
32 | 1 01 02 | 00 92 00 |
33 ----------------------
34 | | | | | |--- Patch number of PCB version
35 | | | | |------ Minor number of PCB version
36 | | | |--------- Major number of PCB version
37 | | |-------------- Product Type, see cs_DeviceTypes.h
38 | |----------------- Market: 1 EU, 2 US
39 |-------------------- Family: 1 Crownstone
40
41 Product type can be:
42 1 Dev, 2 Plug, 3 Builtin, 4 Guidestone, 5 Dongle, 6 Builtin One, 7 Hub, 8 Builtin Two, 9 Plug One, 10 Outlet
43*/
44
59static inline const char* get_hardware_version() {
60
61 uint32_t hardwareBoard = getHardwareBoard();
62
63 // TODO: get hardware version from UICR data.
64
65 switch (hardwareBoard) {
66 // CROWNSTONE PLUGS
67 case ACR01B2A: return "10102000100";
68 case ACR01B2B: return "10102000200";
69 case ACR01B2C: return "10102010000";
70 case ACR01B2E: return "10102010100";
71 case ACR01B2G: return "10102010300";
72
73 // CROWNSTONE BUILTINS
74 case ACR01B1A: return "10103000100";
75 case ACR01B1B: return "10103000200";
76 case ACR01B1C: return "10103000300";
77 case ACR01B1D: return "10103000400";
78 case ACR01B1E: return "10103000500";
79
80 // GUIDESTONE
81 case GUIDESTONE: return "10104010000";
82
83 // CROWNSTONE USB DONGLE
84 case CS_USB_DONGLE: return "10105000000";
85
86 // CROWNSTONE BUILTIN ONES
87 case ACR01B10B: return "10106000000";
88 case ACR01B10D: return "10106000100";
89
90 // CROWNSTONE BUILTIN TWOS
91 case ACR01B13B: return "10108000100";
92 case ACR01B15A: return "10108000200";
93
94 // OUTLETS
95 case CR01R02v4: return "10108000400";
96
97 // Nordic Boards
98 case PCA10036: return "PCA10036";
99 case PCA10040: return "PCA10040";
100 case PCA10100: return "PCA10100";
101 case PCA10056: return "PCA10056";
102
103 default: {
104 return "Unknown";
105 }
106 }
107}
108
109// The string is always 11 chars, add 1 byte for the null terminator.
110static char versionString[12];
111
112static inline const char* get_hardware_version_from_uicr(const cs_uicr_data_t* uicrData) {
113 // Since you can't specify a max width, just use modulo to limit it.
114 sprintf(versionString,
115 "%u%02u%02u%02u%02u%02u",
117 uicrData->productRegionFamily.fields.region % 100,
118 uicrData->productRegionFamily.fields.productType % 100,
119 uicrData->majorMinorPatch.fields.major % 100,
120 uicrData->majorMinorPatch.fields.minor % 100,
121 uicrData->majorMinorPatch.fields.patch % 100);
122 return versionString;
123}
#define ACR01B13B
Definition: cs_Boards.h:64
#define CS_USB_DONGLE
Definition: cs_Boards.h:49
#define ACR01B2G
Definition: cs_Boards.h:84
#define PCA10100
Definition: cs_Boards.h:41
#define GUIDESTONE
Definition: cs_Boards.h:46
#define ACR01B2E
Definition: cs_Boards.h:81
#define ACR01B1A
Definition: cs_Boards.h:54
#define ACR01B1B
Definition: cs_Boards.h:56
#define ACR01B1D
Definition: cs_Boards.h:59
#define ACR01B1C
Definition: cs_Boards.h:58
#define ACR01B15A
Definition: cs_Boards.h:65
#define ACR01B2B
Definition: cs_Boards.h:73
#define PCA10040
Definition: cs_Boards.h:39
#define ACR01B2C
Definition: cs_Boards.h:76
#define ACR01B2A
Definition: cs_Boards.h:70
#define ACR01B1E
Definition: cs_Boards.h:60
#define ACR01B10D
Definition: cs_Boards.h:62
#define CR01R02v4
Definition: cs_Boards.h:92
#define ACR01B10B
Definition: cs_Boards.h:61
#define PCA10036
We use part of the UICR to store information about the hardware board.
Definition: cs_Boards.h:37
#define PCA10056
Definition: cs_Boards.h:43
static const char * get_hardware_version()
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 21,...
Definition: cs_HardwareVersions.h:59
static char versionString[12]
Definition: cs_HardwareVersions.h:110
static const char * get_hardware_version_from_uicr(const cs_uicr_data_t *uicrData)
Definition: cs_HardwareVersions.h:112
uint32_t getHardwareBoard()
Get the hardware board from UICR, or the default board if none is set in UICR.
Struct with all the Crownstone fields in UICR.
Definition: cs_UicrPacket.h:20
uint8_t productFamily
Definition: cs_UicrPacket.h:27
uint8_t major
Definition: cs_UicrPacket.h:37
struct cs_uicr_data_t::@35::@38 fields
uint8_t region
Definition: cs_UicrPacket.h:26
uint8_t productType
Definition: cs_UicrPacket.h:25
uint8_t patch
Definition: cs_UicrPacket.h:35
union cs_uicr_data_t::@35 productRegionFamily
uint8_t minor
Definition: cs_UicrPacket.h:36
union cs_uicr_data_t::@36 majorMinorPatch