Add GD-77 zone CPS support
This commit is contained in:
parent
6755a4a7e5
commit
a86176dcb8
|
|
@ -116,15 +116,20 @@ typedef struct {
|
||||||
}
|
}
|
||||||
gdxChannelBank_t;
|
gdxChannelBank_t;
|
||||||
|
|
||||||
|
// This corresponds to OpenGD77 extended zones
|
||||||
|
// TODO: Find a way to distinguish between a stock and OpenGD77 CPS
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Bytes 0-15
|
|
||||||
uint8_t name[16]; // Zone Name
|
uint8_t name[16]; // Zone Name
|
||||||
|
uint16_t member[80]; // Member: channels 1...80
|
||||||
// Bytes 16-47
|
|
||||||
uint16_t member[16]; // Member: channels 1...16
|
|
||||||
}
|
}
|
||||||
gdxZone_t;
|
gdxZone_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t bitmap[32]; // bit set when zone valid
|
||||||
|
gdxZone_t zone[250];
|
||||||
|
}
|
||||||
|
gdxZoneBank_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Bytes 0-15
|
// Bytes 0-15
|
||||||
uint8_t name[16]; // Contact Name, ff terminated
|
uint8_t name[16]; // Contact Name, ff terminated
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,14 @@ static const uint32_t VHF_CAL_BASE = 0x6F070;
|
||||||
#warning GDx calibration: platform not supported
|
#warning GDx calibration: platform not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//const uint32_t zoneBaseAddr = 0x149e0; /**< Base address of zones */
|
//const uint32_t zoneBaseAddr = 0x149e0; /**< Base address of zones */
|
||||||
const uint32_t channelBaseAddrEEPROM = 0x03780; /**< Base address of channel data */
|
const uint32_t channelBaseAddrEEPROM = 0x03780; /**< Base address of channel data */
|
||||||
const uint32_t channelBaseAddrFlash = 0x7b1c0; /**< Base address of channel data */
|
const uint32_t channelBaseAddrFlash = 0x7b1c0; /**< Base address of channel data */
|
||||||
const uint32_t contactBaseAddr = 0x87620; /**< Base address of contacts */
|
const uint32_t zoneBaseAddr = 0x8010; /**< Base address of zones */
|
||||||
const uint32_t maxNumChannels = 1024; /**< Maximum number of channels in memory */
|
const uint32_t contactBaseAddr = 0x87620; /**< Base address of contacts */
|
||||||
const uint32_t maxNumZones = 68; /**< Maximum number of zones in memory */
|
const uint32_t maxNumChannels = 1024; /**< Maximum number of channels in memory */
|
||||||
const uint32_t maxNumContacts = 1024; /**< Maximum number of contacts in memory */
|
const uint32_t maxNumZones = 68; /**< Maximum number of zones in memory */
|
||||||
|
const uint32_t maxNumContacts = 1024; /**< Maximum number of contacts in memory */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \internal Utility function to convert 4 byte BCD values into a 32-bit
|
* \internal Utility function to convert 4 byte BCD values into a 32-bit
|
||||||
|
|
@ -288,9 +289,32 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
|
||||||
|
|
||||||
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
||||||
{
|
{
|
||||||
(void) zone;
|
if((pos <= 0) || (pos > maxNumZones)) return -1;
|
||||||
(void) pos;
|
|
||||||
return -1;
|
// ### Read zone bank bitmap ###
|
||||||
|
uint8_t bitmap[32];
|
||||||
|
AT24Cx_readData(zoneBaseAddr, ((uint8_t *) &bitmap), sizeof(bitmap));
|
||||||
|
|
||||||
|
uint8_t bitmap_byte = pos / 8;
|
||||||
|
uint8_t bitmap_bit = pos % 8;
|
||||||
|
// The zone is marked not valid in the bitmap
|
||||||
|
if(!(bitmap[bitmap_byte] & (1 << bitmap_bit))) return -1;
|
||||||
|
|
||||||
|
gdxZone_t zoneData;
|
||||||
|
// Note: pos is 1-based to be consistent with channels
|
||||||
|
uint32_t zoneAddr = zoneBaseAddr + sizeof(bitmap) + (pos - 1) * sizeof(gdxZone_t);
|
||||||
|
AT24Cx_readData(zoneAddr, ((uint8_t *) &zoneData), sizeof(gdxZone_t));
|
||||||
|
|
||||||
|
// Check if zone is empty
|
||||||
|
if(wcslen((wchar_t *) zoneData.name) == 0) return -1;
|
||||||
|
|
||||||
|
memcpy(zone->name, zoneData.name, sizeof(zoneData.name));
|
||||||
|
// Copy zone channel indexes
|
||||||
|
for(uint16_t i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
zone->member[i] = zoneData.member[i];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nvm_readContactData(contact_t *contact, uint16_t pos)
|
int nvm_readContactData(contact_t *contact, uint16_t pos)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue