Skip to content

Commit 85c6abd

Browse files
committed
Merge pull request #224 from nomis52/id
Handle multiple microchip OIDs.
2 parents 2054579 + ea70768 commit 85c6abd

File tree

23 files changed

+245
-77
lines changed

23 files changed

+245
-77
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ make
6565
make check
6666
```
6767

68+
## PLASA Identifiers & UIDs
69+
70+
The code by default uses the Open Lighting PLASA ID (0x7a70). This range is
71+
owned by the Open Lighting Project and at this time we do not sub-license
72+
ranges to anyone else. You *may not* ship product with the Open Lighting
73+
PLASA ID.
74+
75+
Per https://wiki.openlighting.org/index.php/Open_Lighting_Allocations the
76+
UIDs 7a70:fffffe00 to 7a70:fffffefe may be used for development (in house)
77+
purposes.
78+
6879
## Dev Notes
6980

7081
A bulk-in transfer with a full 512 bytes of DMX data takes < 1ms on my mac

boardcfg/ethernet_sk2/bootloader_settings.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include "bootloader.h"
2424
#include "common_settings.h"
25-
#include "config_options.h"
2625

2726
#ifdef __cplusplus
2827
extern "C" {
@@ -74,12 +73,6 @@ extern "C" {
7473
*/
7574
#define SWITCH_ACTIVE_HIGH false
7675

77-
/**
78-
* @brief The hardware model.
79-
* @sa JaRuleModel
80-
*/
81-
#define HARDWARE_MODEL MODEL_ETHERNET_SK2
82-
8376
/**
8477
* @brief The LEDS to flash in bootloader mode.
8578
*/

boardcfg/ethernet_sk2/common_settings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ extern "C" {
6666
*/
6767
#define CFG_UID_SOURCE CFG_OPT_UID_FROM_MAC
6868

69+
/**
70+
* @brief The hardware model.
71+
* @sa JaRuleModel
72+
*/
73+
#define HARDWARE_MODEL MODEL_ETHERNET_SK2
74+
6975
/**
7076
* @}
7177
*

boardcfg/number1/bootloader_settings.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include "bootloader.h"
2424
#include "common_settings.h"
25-
#include "config_options.h"
2625

2726
#ifdef __cplusplus
2827
extern "C" {
@@ -74,12 +73,6 @@ extern "C" {
7473
*/
7574
#define SWITCH_ACTIVE_HIGH false
7675

77-
/**
78-
* @brief The hardware model.
79-
* @sa JaRuleModel
80-
*/
81-
#define HARDWARE_MODEL MODEL_NUMBER1
82-
8376
/**
8477
* @brief The LEDS to flash in bootloader mode.
8578
*/

boardcfg/number1/common_settings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ extern "C" {
6666
*/
6767
#define CFG_UID_SOURCE CFG_OPT_UID_FROM_MAC
6868

69+
/**
70+
* @brief The hardware model.
71+
* @sa JaRuleModel
72+
*/
73+
#define HARDWARE_MODEL MODEL_NUMBER1
74+
6975
/**
7076
* @}
7177
*

boardcfg/number8/bootloader_settings.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include "bootloader.h"
2424
#include "common_settings.h"
25-
#include "config_options.h"
2625

2726
#ifdef __cplusplus
2827
extern "C" {
@@ -74,12 +73,6 @@ extern "C" {
7473
*/
7574
#define SWITCH_ACTIVE_HIGH false
7675

77-
/**
78-
* @brief The hardware model.
79-
* @sa JaRuleModel
80-
*/
81-
#define HARDWARE_MODEL MODEL_NUMBER8
82-
8376
/**
8477
* @brief The LEDS to flash in bootloader mode.
8578
*/

boardcfg/number8/common_settings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ extern "C" {
6666
*/
6767
#define CFG_UID_SOURCE CFG_OPT_UID_FROM_MAC
6868

69+
/**
70+
* @brief The hardware model.
71+
* @sa JaRuleModel
72+
*/
73+
#define HARDWARE_MODEL MODEL_NUMBER8
74+
6975
/**
7076
* @}
7177
*

boardcfg/template/bootloader_settings.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ extern "C" {
7474
*/
7575
#define SWITCH_ACTIVE_HIGH false
7676

77-
/**
78-
* @brief The hardware model.
79-
* @sa JaRuleModel
80-
*/
81-
#define HARDWARE_MODEL MODEL_UNDEFINED
82-
8377
/**
8478
* @brief The LEDS to flash in bootloader mode.
8579
*/

boardcfg/template/common_settings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ extern "C" {
6666
*/
6767
#define CFG_UID_SOURCE CFG_OPT_UID_FROM_MAC
6868

69+
/**
70+
* @brief The hardware model.
71+
* @sa JaRuleModel
72+
*/
73+
#define HARDWARE_MODEL MODEL_UNDEFINED
74+
6975
/**
7076
* @}
7177
*

common/uid_store.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "peripheral/eth/plib_eth.h"
3232

3333
static uint8_t kUIDArray[UID_LENGTH];
34+
static const uint32_t MICROCHIP_OID1 = 0x00001ec0;
35+
static const uint32_t MICROCHIP_OID2 = 0x00d88039;
3436

3537
inline uint8_t ShiftRight(uint8_t b) {
3638
return (b >> 4) & 0x0f;
@@ -42,23 +44,49 @@ inline uint8_t ShiftLeft(uint8_t b) {
4244

4345
void UIDStore_Init() {
4446
// The UID is derived from the RDM manufacturer ID & the MAC address.
45-
// The first 3 bytes of the MAC address is the Microchip OID 00:1e:c0 which
46-
// is constant. The bottom 3 bytes contain the unique serial number.
47+
// The first 3 bytes of the MAC address is the Microchip OIDs, which are one
48+
// of 00:1E:C0, 00:04:A3 or D8:80:39. The bottom 3 bytes contain the unique
49+
// serial number.
4750
//
4851
// To support more than one responder per device, we set the lower 4 bits of
4952
// the UID to 0 so we have 16 responders per device. These means the complete
5053
// UID takes the form:
51-
// MMMM:1AAAAAA0
52-
// Where M is the PLASA manufacturer ID and A are the values from the MAC
53-
// address.
54-
kUIDArray[0] = CFG_MANUFACTURER_ID >> 8;
55-
kUIDArray[1] = CFG_MANUFACTURER_ID & 0xff;
56-
kUIDArray[2] = 0x10 + ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 4));
57-
kUIDArray[3] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 4)) +
58-
ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 5));
59-
kUIDArray[4] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 5)) +
60-
ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 6));
61-
kUIDArray[5] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 6));
54+
// MMMM:XAAAAAA0
55+
// Where M is the PLASA manufacturer ID, X is derived from the OID and A is
56+
// the values from the MAC address. X is derived from the OID as follows:
57+
//
58+
// 00:1E:C0 -> 1
59+
// D8:80:39 -> 2
60+
uint32_t oid = (PLIB_ETH_StationAddressGet(ETH_ID_0, 1) << 16) +
61+
(PLIB_ETH_StationAddressGet(ETH_ID_0, 2) << 8) +
62+
PLIB_ETH_StationAddressGet(ETH_ID_0, 3);
63+
uint8_t upper_id = 0;
64+
if (oid == MICROCHIP_OID1) {
65+
upper_id = 0x10;
66+
} else if (oid == MICROCHIP_OID2) {
67+
upper_id = 0x20;
68+
}
69+
70+
if (upper_id) {
71+
kUIDArray[0] = CFG_MANUFACTURER_ID >> 8;
72+
kUIDArray[1] = CFG_MANUFACTURER_ID & 0xff;
73+
kUIDArray[2] = upper_id +
74+
ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 4));
75+
kUIDArray[3] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 4)) +
76+
ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 5));
77+
kUIDArray[4] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 5)) +
78+
ShiftRight(PLIB_ETH_StationAddressGet(ETH_ID_0, 6));
79+
kUIDArray[5] = ShiftLeft(PLIB_ETH_StationAddressGet(ETH_ID_0, 6));
80+
} else {
81+
// If we didn't match the OID, default to the NULL UID to make it obvious
82+
// what happened
83+
kUIDArray[0] = 0;
84+
kUIDArray[1] = 0;
85+
kUIDArray[2] = 0;
86+
kUIDArray[3] = 0;
87+
kUIDArray[4] = 0;
88+
kUIDArray[5] = 0;
89+
}
6290
}
6391

6492
const uint8_t* const kUID = &kUIDArray[0];

0 commit comments

Comments
 (0)