Skip to content

Commit

Permalink
check for gpiochip455
Browse files Browse the repository at this point in the history
  • Loading branch information
gl-chenxiaosheng committed Apr 11, 2024
1 parent f332717 commit cd5cdaf
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/bledriver/util/gl_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int check_endian(void);
static int serial_init(void);
static GL_RET get_model_hw_cfg(void);
static GL_RET normal_check_rst_io(void);
static GL_RET qsdk_check_ver(void);
static GL_RET sdk_check_ver(void);

struct uci_context* guci2_init(void);
int guci2_free(struct uci_context* ctx);
Expand Down Expand Up @@ -106,23 +106,30 @@ static GL_RET normal_check_rst_io(void)
}

/* Check openwrt version
QSDK in official openwrt will have a special io base num.
SDK in official openwrt will have a special io base num.
If "/sys/class/gpio/gpiochip412" exist, all io shoule add 412.
If "/sys/class/gpio/gpiochip455" exist, all io shoule add 455.
*/
#define SPECIAL_CHIP_IO "/sys/class/gpio/gpiochip412"
static GL_RET qsdk_check_ver(void)
#define SPECIAL_CHIP_IO412 "/sys/class/gpio/gpiochip412"
#define SPECIAL_CHIP_IO455 "/sys/class/gpio/gpiochip455"
static GL_RET sdk_check_ver(void)
{
if(!ble_hw_cfg)
{
log_err("HW cfg lost!\n");
return GL_UNKNOW_ERR;
}

if((access(SPECIAL_CHIP_IO, F_OK)) != -1)
if((access(SPECIAL_CHIP_IO412, F_OK)) != -1)
{
log_debug("QSDK gpiochip412 exist.\n");
log_debug("SDK gpiochip412 exist.\n");
ble_hw_cfg->rst_gpio += 412;
}
else if((access(SPECIAL_CHIP_IO455, F_OK)) != -1)
{
log_debug("SDK gpiochip455 exist.\n");
ble_hw_cfg->rst_gpio += 455;
}

return GL_SUCCESS;
}
Expand Down Expand Up @@ -162,7 +169,7 @@ static GL_RET find_model_hw(char *model_name)
if(0 == strcmp(model_name, GL_BLE_HW_LIST[i].model))
{
ble_hw_cfg = &GL_BLE_HW_LIST[i];
qsdk_check_ver();
sdk_check_ver();
return GL_SUCCESS;
}
}
Expand Down

0 comments on commit cd5cdaf

Please sign in to comment.