Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/board/hani_iot.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0360",
.family_id = VENDOR_TO_FAMILY(kNXP_VendorID, 0), //ID not maching the predefined family ids
.family_id = kNXP_LPC55xx_FamilyID, //ID not maching the predefined family ids
.flags = kEnablePageErase,
.daplink_url_name = "PRODINFOHTM",
.daplink_drive_name = "HANI_IOT",
Expand Down
2 changes: 1 addition & 1 deletion source/board/lpc55S69xpresso.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0236",
.family_id = VENDOR_TO_FAMILY(kNXP_VendorID, 0), //ID not maching the predefined family ids
.family_id = kNXP_LPC55xx_FamilyID,
.flags = kEnablePageErase,
.daplink_url_name = "PRODINFOHTM",
.daplink_drive_name = "LPC55S69",
Expand Down
2 changes: 1 addition & 1 deletion source/family/nxp/lpc55S6X/target_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static uint8_t lpc55s6x_target_set_state(target_state_t state)
}

const target_family_descriptor_t g_target_family_lpc55S6X = {
.family_id = VENDOR_TO_FAMILY(kNXP_VendorID, 0), //ID not maching the predefined family ids
.family_id = kNXP_LPC55xx_FamilyID, //ID not maching the predefined family ids
.target_set_state = lpc55s6x_target_set_state,
};

Expand Down
78 changes: 41 additions & 37 deletions source/target/target_family.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,34 @@ const target_family_descriptor_t g_sw_sysresetreq_family = {
.soft_reset_type = SYSRESETREQ,
};

//Weakly define family
__attribute__((weak))
const target_family_descriptor_t g_nxp_kinetis_kseries = {0};
__attribute__((weak))
const target_family_descriptor_t g_nxp_kinetis_lseries = {0};
__attribute__((weak))
const target_family_descriptor_t g_nxp_kinetis_k32w_series = {0};
__attribute__((weak))
const target_family_descriptor_t g_nxp_mimxrt = {0};
__attribute__((weak))
const target_family_descriptor_t g_nxp_rapid_iot = {0};
__attribute__((weak))
const target_family_descriptor_t g_nordic_nrf51 = {0};
__attribute__((weak))
const target_family_descriptor_t g_nordic_nrf52 = {0};
__attribute__((weak))
const target_family_descriptor_t g_realtek_rtl8195am = {0};
__attribute__((weak))
const target_family_descriptor_t g_ti_family = {0};
__attribute__((weak))
const target_family_descriptor_t g_wiznet_family = {0};
__attribute__((weak))
const target_family_descriptor_t g_renesas_family = {0};
__attribute__((weak))
const target_family_descriptor_t g_toshiba_tz_family = {0};
__attribute__((weak))
const target_family_descriptor_t g_ambiq_ama3b1kk = {0};
// Weak references to family definitions.
extern __WEAK const target_family_descriptor_t g_nxp_kinetis_kseries;
extern __WEAK const target_family_descriptor_t g_nxp_kinetis_lseries;
extern __WEAK const target_family_descriptor_t g_nxp_kinetis_k32w_series;
extern __WEAK const target_family_descriptor_t g_nxp_mimxrt;
extern __WEAK const target_family_descriptor_t g_nxp_rapid_iot;
extern __WEAK const target_family_descriptor_t g_nxp_lpc55xx_series;
extern __WEAK const target_family_descriptor_t g_nordic_nrf51;
extern __WEAK const target_family_descriptor_t g_nordic_nrf52;
extern __WEAK const target_family_descriptor_t g_realtek_rtl8195am;
extern __WEAK const target_family_descriptor_t g_ti_family;
extern __WEAK const target_family_descriptor_t g_wiznet_family;
extern __WEAK const target_family_descriptor_t g_renesas_family;
extern __WEAK const target_family_descriptor_t g_toshiba_tz_family;
extern __WEAK const target_family_descriptor_t g_ambiq_ama3b1kk;

//! @brief Terminator value for g_families list.
//!
//! This terminator value is chosen so that weak references to the family descriptors that
//! resolve to NULL at link time do not terminate the list early.
#define FAMILY_LIST_TERMINATOR ((const target_family_descriptor_t *)(0xffffffff))

//! @brief Default list of family descriptors.
//!
//! init_family() scans this list searching for a family descriptor with an ID that matches
//! the family ID set in the board info or target config structs. Because each of the family
//! descriptors has a weak reference defined above, the entry in this list for a family whose
//! descriptor is not included in the link will resolve to NULL and init_family() can skip it.
__attribute__((weak))
const target_family_descriptor_t *g_families[] = {
&g_hw_reset_family,
Expand All @@ -80,6 +79,7 @@ const target_family_descriptor_t *g_families[] = {
&g_nxp_kinetis_kseries,
&g_nxp_kinetis_lseries,
&g_nxp_kinetis_k32w_series,
&g_nxp_lpc55xx_series,
&g_nxp_mimxrt,
&g_nxp_rapid_iot,
&g_nordic_nrf51,
Expand All @@ -90,7 +90,7 @@ const target_family_descriptor_t *g_families[] = {
&g_renesas_family,
&g_toshiba_tz_family,
&g_ambiq_ama3b1kk,
0 // list terminator
FAMILY_LIST_TERMINATOR // list terminator
};

__attribute__((weak))
Expand All @@ -99,21 +99,25 @@ const target_family_descriptor_t *g_target_family = NULL;

void init_family(void)
{
uint8_t index = 0;
uint16_t family_id = get_family_id();
if (g_target_family != NULL){ //already set
// Check if the family is already set.
if (g_target_family != NULL) {
return;
}

while (g_families[index]!=0) {
if (g_families[index]->family_id && (g_families[index]->family_id == family_id)) {
// Scan families table looking for matching family ID.
uint8_t index = 0;
uint16_t family_id = get_family_id();

while (g_families[index] != FAMILY_LIST_TERMINATOR) {
if ((g_families[index] != NULL) && (g_families[index]->family_id == family_id)) {
g_target_family = g_families[index];
break;
}
index++;
}

if(g_target_family == NULL){ //default family
// Last resort is to use a default family.
if (g_target_family == NULL) {
g_target_family = &g_hw_reset_family;
}
}
Expand All @@ -137,11 +141,11 @@ uint8_t target_set_state(target_state_t state)
swd_set_soft_reset(g_target_family->soft_reset_type);
}
return swd_set_target_state_sw(state);
}else {
} else {
return 1;
}
}
}else{
} else {
return 0;
}
}
Expand All @@ -150,7 +154,7 @@ void swd_set_target_reset(uint8_t asserted)
{
if (g_target_family && g_target_family->swd_set_target_reset) {
g_target_family->swd_set_target_reset(asserted);
}else {
} else {
(asserted) ? PIN_nRESET_OUT(0) : PIN_nRESET_OUT(1);
}
}
Expand Down
1 change: 1 addition & 0 deletions source/target/target_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ typedef enum _family_id {
kNXP_Mimxrt_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 3),
kNXP_RapidIot_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 4),
kNXP_KinetisK32W_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 5),
kNXP_LPC55xx_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 6),
kNordic_Nrf51_FamilyID = VENDOR_TO_FAMILY(kNordic_VendorID, 1),
kNordic_Nrf52_FamilyID = VENDOR_TO_FAMILY(kNordic_VendorID, 2),
kRealtek_Rtl8195am_FamilyID = VENDOR_TO_FAMILY(kRealtek_VendorID, 1),
Expand Down