Applied __attribute__((packed)) to all data structures to reduce memory footprint
This commit is contained in:
parent
9d02ffaea4
commit
86f6d114e2
|
|
@ -56,7 +56,8 @@ typedef struct
|
|||
rxTone : 7; /**< RX CTC/DCS tone index, squelch opens on match */
|
||||
uint8_t txToneEn : 1, /**< TX CTC/DCS tone enable */
|
||||
txTone : 7; /**< TX CTC/DCS tone index, sent alongside voice */
|
||||
} fmInfo_t;
|
||||
}
|
||||
__attribute__((packed)) fmInfo_t;
|
||||
|
||||
/**
|
||||
* Data structure containing all and only the information for DMR channels.
|
||||
|
|
@ -68,7 +69,8 @@ typedef struct
|
|||
|
||||
uint8_t dmr_timeslot; /**< DMR timeslot, either 1 or 2 */
|
||||
uint16_t contactName_index; /**< Index to retrieve data from contact list */
|
||||
} dmrInfo_t;
|
||||
}
|
||||
__attribute__((packed)) dmrInfo_t;
|
||||
|
||||
/**
|
||||
* Data structure containing all the information of a channel, either FM or DMR.
|
||||
|
|
@ -101,7 +103,8 @@ typedef struct
|
|||
fmInfo_t fm; /**< Information block for FM channels */
|
||||
dmrInfo_t dmr; /**< Information block for DMR channels */
|
||||
};
|
||||
} channel_t;
|
||||
}
|
||||
__attribute__((packed)) channel_t;
|
||||
|
||||
/**
|
||||
* Data structure containing all the information of a zone.
|
||||
|
|
@ -110,7 +113,8 @@ typedef struct
|
|||
{
|
||||
char name[16]; /**< Zone name */
|
||||
uint16_t member[64]; /**< Channel indexes */
|
||||
} zone_t;
|
||||
}
|
||||
__attribute__((packed)) zone_t;
|
||||
|
||||
/**
|
||||
* Data structure containing all the information of a contact.
|
||||
|
|
@ -121,6 +125,7 @@ typedef struct
|
|||
uint32_t id; /**< DMR ID: 24bit number, 1...16777215 */
|
||||
uint8_t type; /**< Call Type: Group Call, Private Call or All Call */
|
||||
bool receive_tone; /**< Call Receive Tone: No or yes */
|
||||
} contact_t;
|
||||
}
|
||||
__attribute__((packed)) contact_t;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ typedef struct queue_t
|
|||
uint8_t write_pos;
|
||||
uint8_t msg_num;
|
||||
uint32_t buffer[MSG_QTY];
|
||||
} queue_t;
|
||||
}
|
||||
queue_t;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ typedef struct
|
|||
uint16_t txToneEn : 1, /**< TX CTC/DCS tone enable */
|
||||
txTone : 15; /**< TX CTC/DCS tone */
|
||||
}
|
||||
rtxStatus_t;
|
||||
__attribute__((packed)) rtxStatus_t;
|
||||
|
||||
/**
|
||||
* \enum bandwidth Enumeration type defining the current rtx bandwidth.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ typedef struct
|
|||
uint16_t azimuth; // Azimuth in degrees
|
||||
uint8_t snr; // Quality of the signal in range 0-99
|
||||
}
|
||||
sat_t;
|
||||
__attribute__((packed)) sat_t;
|
||||
|
||||
/**
|
||||
* Data structure representing the last state received from the GPS module.
|
||||
|
|
@ -58,7 +58,7 @@ typedef struct
|
|||
float tmg_mag; // Course over ground, degrees, magnetic
|
||||
float tmg_true; // Course over ground, degrees, true
|
||||
}
|
||||
gps_t;
|
||||
__attribute__((packed)) gps_t;
|
||||
|
||||
/**
|
||||
* Part of this structure has been commented because the corresponding
|
||||
|
|
@ -96,7 +96,7 @@ typedef struct
|
|||
settings_t settings;
|
||||
gps_t gps_data;
|
||||
}
|
||||
state_t;
|
||||
__attribute__((packed)) state_t;
|
||||
|
||||
enum TunerMode
|
||||
{
|
||||
|
|
|
|||
|
|
@ -136,9 +136,10 @@ typedef struct layout_t
|
|||
fontSize_t bottom_font;
|
||||
fontSize_t input_font;
|
||||
fontSize_t menu_font;
|
||||
} layout_t;
|
||||
}
|
||||
__attribute__((packed)) layout_t;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This structs contains state variables internal to the
|
||||
* UI that need to be kept between executions of the UI
|
||||
* This state does not need to be saved on device poweroff
|
||||
|
|
@ -165,7 +166,8 @@ typedef struct ui_state_t
|
|||
#endif
|
||||
// Which state to return to when we exit menu
|
||||
uint8_t last_main_state;
|
||||
} ui_state_t;
|
||||
}
|
||||
__attribute__((packed)) ui_state_t;
|
||||
|
||||
extern layout_t layout;
|
||||
// Copy of the radio state
|
||||
|
|
@ -188,7 +190,7 @@ extern const color_t color_white;
|
|||
extern const color_t yellow_fab413;
|
||||
|
||||
/**
|
||||
* This function initialises the User Interface, starting the
|
||||
* This function initialises the User Interface, starting the
|
||||
* Finite State Machine describing the user interaction.
|
||||
*/
|
||||
void ui_init();
|
||||
|
|
@ -208,7 +210,7 @@ void ui_drawSplashScreen(bool centered);
|
|||
void ui_saveState();
|
||||
|
||||
/**
|
||||
* This function advances the User Interface FSM, basing on the
|
||||
* This function advances the User Interface FSM, basing on the
|
||||
* current radio state and the keys pressed.
|
||||
* @param last_state: A local copy of the previous radio state
|
||||
* @param event: An event from other threads
|
||||
|
|
|
|||
|
|
@ -108,13 +108,13 @@ typedef struct {
|
|||
// Bytes 52-55
|
||||
uint8_t _unused52[4]; // 0
|
||||
}
|
||||
gdxChannel_t;
|
||||
__attribute__((packed)) gdxChannel_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t bitmap[16]; // bit set when channel valid
|
||||
gdxChannel_t chan[128];
|
||||
}
|
||||
gdxChannelBank_t;
|
||||
}
|
||||
__attribute__((packed)) gdxChannelBank_t;
|
||||
|
||||
// This corresponds to OpenGD77 extended zones
|
||||
// TODO: Find a way to distinguish between a stock and OpenGD77 CPS
|
||||
|
|
@ -122,13 +122,13 @@ typedef struct {
|
|||
uint8_t name[16]; // Zone Name
|
||||
uint16_t member[80]; // Member: channels 1...80
|
||||
}
|
||||
gdxZone_t;
|
||||
__attribute__((packed)) gdxZone_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t bitmap[32]; // bit set when zone valid
|
||||
gdxZone_t zone[250];
|
||||
}
|
||||
gdxZoneBank_t;
|
||||
__attribute__((packed)) gdxZoneBank_t;
|
||||
|
||||
typedef struct {
|
||||
// Bytes 0-15
|
||||
|
|
@ -145,6 +145,6 @@ typedef struct {
|
|||
uint8_t ring_style; // Ring style: 0-10
|
||||
uint8_t _unused23; // 0xff for used contact, 0 for blank entry
|
||||
}
|
||||
gdxContact_t;
|
||||
__attribute__((packed)) gdxContact_t;
|
||||
|
||||
#endif /* NVMDATA_GDx_H */
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ typedef struct
|
|||
// Bytes 32-63
|
||||
uint16_t name[16];
|
||||
}
|
||||
md3x0Channel_t;
|
||||
__attribute__((packed)) md3x0Channel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -120,7 +120,7 @@ typedef struct
|
|||
// Bytes 32-63
|
||||
uint16_t member[16]; // Member: channels 1...16
|
||||
}
|
||||
md3x0Zone_t;
|
||||
__attribute__((packed)) md3x0Zone_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -135,6 +135,6 @@ typedef struct
|
|||
// Bytes 4-35
|
||||
uint16_t name[16]; // Contact Name (Unicode)
|
||||
}
|
||||
md3x0Contact_t;
|
||||
__attribute__((packed)) md3x0Contact_t;
|
||||
|
||||
#endif /* NVMDATA_MD3x0_H */
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ typedef struct
|
|||
// Bytes 32-63
|
||||
uint16_t name[16];
|
||||
}
|
||||
mduv3x0Channel_t;
|
||||
__attribute__((packed)) mduv3x0Channel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ typedef struct
|
|||
// Bytes 32-63
|
||||
uint16_t member_a[16]; // Member A: channels 1...16
|
||||
}
|
||||
mduv3x0Zone_t;
|
||||
__attribute__((packed)) mduv3x0Zone_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -134,7 +134,7 @@ typedef struct
|
|||
// Bytes 96-223
|
||||
uint16_t member_b[64]; // Member B: channels 1...64
|
||||
}
|
||||
mduv3x0ZoneExt_t;
|
||||
__attribute__((packed)) mduv3x0ZoneExt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -149,6 +149,6 @@ typedef struct
|
|||
// Bytes 4-35
|
||||
uint16_t name[16]; // Contact Name (Unicode)
|
||||
}
|
||||
mduv3x0Contact_t;
|
||||
__attribute__((packed)) mduv3x0Contact_t;
|
||||
|
||||
#endif /* NVMDATA_MDUV3x0_H */
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ int _nvm_readChannelAtAddress(channel_t *channel, uint32_t addr)
|
|||
W25Qx_sleep();
|
||||
|
||||
// Check if the channel is empty
|
||||
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||
if(wcslen((wchar_t *) chData.name) == 0) return -1;
|
||||
|
||||
channel->mode = chData.channel_mode - 1;
|
||||
|
|
@ -298,6 +299,7 @@ int nvm_readZoneData(zone_t *zone, uint16_t pos)
|
|||
W25Qx_sleep();
|
||||
|
||||
// Check if zone is empty
|
||||
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||
if(wcslen((wchar_t *) zoneData.name) == 0) return -1;
|
||||
/*
|
||||
* Brutally convert channel name from unicode to char by truncating the most
|
||||
|
|
|
|||
Loading…
Reference in New Issue