Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have all the register macro grouped together instead of with its register data structure definition #3

Open
TMarkivULCRobotics opened this issue Feb 2, 2022 · 0 comments

Comments

@TMarkivULCRobotics
Copy link

It is easier to use and edit register address macro when they are grouped together instead of scattered all over the file. For example I wanted to create an array that countains all of the imu registers:

stc_imu_data_t imu_data[] =
{
    {ASM330LHH_REG_PIN_CTRL,           &pin_ctrl.buf},
    {ASM330LHH_REG_FIFO_CTRL1,         &fifo_ctrl1.buf},
    {ASM330LHH_REG_FIFO_CTRL2,         &fifo_ctrl2.buf},
    {ASM330LHH_REG_FIFO_CTRL3,         &fifo_ctrl3.buf},
    {ASM330LHH_REG_FIFO_CTRL4,         &fifo_ctrl4.buf},
    {ASM330LHH_REG_COUNTER_BDR_REG1,   &counter_bdr_reg1_t.buf},
    {ASM330LHH_REG_COUNTER_BDR_REG2,   &counter_bdr_reg2_t.buf},
    {ASM330LHH_REG_INT1_CTRL,          &int1_ctrl.buf},
    {ASM330LHH_REG_INT2_CTRL,          &int2_ctrl.buf},
    {ASM330LHH_REG_WHO_AM_I,           &who_am_i.buf},
    {ASM330LHH_REG_CTRL1_XL,           &ctrl1_xl.buf},
    {ASM330LHH_REG_CTRL2_G,            &ctrl2_g.buf},
    {ASM330LHH_REG_CTRL3_C,            &ctrl3_c.buf},
    {ASM330LHH_REG_CTRL4_C,            &ctrl4_c.buf},
    {ASM330LHH_REG_CTRL5_C,            &ctrl5_c.buf},
    {ASM330LHH_REG_CTRL6_C,            &ctrl6_c.buf},
    {ASM330LHH_REG_CTRL7_G,            &ctrl7_g.buf},
    {ASM330LHH_REG_CTRL8_XL,           &ctrl8_xl.buf},
    {ASM330LHH_REG_CTRL9_XL,           &ctrl9_xl.buf},
    {ASM330LHH_REG_CTRL10_C,           &ctrl10_c.buf},
    {ASM330LHH_REG_ALL_INT_SRC,        &all_int_src.buf},
    {ASM330LHH_REG_WAKE_UP_SRC,        &wake_up_src.buf},
    {ASM330LHH_REG_TAP_SRC,            &tap_src.buf},
    {ASM330LHH_REG_D6D_SRC,            &d6d_src.buf},
    {ASM330LHH_REG_STATUS_REG,         &status_reg.buf},
    {ASM330LHH_REG_OUT_TEMP_L,         &out_temp_l.buf},
    {ASM330LHH_REG_OUT_TEMP_H,         &out_temp_h.buf},
    {ASM330LHH_REG_OUTX_L_G,           &outx_l_g.buf},
    {ASM330LHH_REG_OUTX_H_G,           &outx_h_g.buf},
    {ASM330LHH_REG_OUTY_L_G,           &outy_l_g.buf},
    {ASM330LHH_REG_OUTY_H_G,           &outy_h_g.buf},
    {ASM330LHH_REG_OUTZ_L_G,           &outz_l_g.buf},
    {ASM330LHH_REG_OUTZ_H_G,           &outz_h_g.buf},
    {ASM330LHH_REG_OUTX_L_A,           &outx_l_a.buf},
    {ASM330LHH_REG_OUTX_H_A,           &outx_h_a.buf},
    {ASM330LHH_REG_OUTY_L_A,           &outy_l_a.buf},
    {ASM330LHH_REG_OUTY_H_A,           &outy_h_a.buf},
    {ASM330LHH_REG_OUTZ_L_A,           &outz_l_a.buf},
    {ASM330LHH_REG_OUTZ_H_A,           &outz_h_a.buf},
    {ASM330LHH_REG_FIFO_STATUS1,       &fifo_status1.buf},
    {ASM330LHH_REG_FIFO_STATUS2,       &fifo_status2.buf},
    {ASM330LHH_REG_TIMESTAMP0,         &timestamp0.buf},
    {ASM330LHH_REG_TIMESTAMP1,         &timestamp1.buf},
    {ASM330LHH_REG_TIMESTAMP2,         &timestamp2.buf},
    {ASM330LHH_REG_TIMESTAMP3,         &timestamp3.buf},
    {ASM330LHH_REG_INT_CFG0,           &int_cfg0_t.buf},
    {ASM330LHH_REG_INT_CFG1,           &int_cfg1_t.buf},
    {ASM330LHH_REG_THS_6D,             &ths_6d_t.buf},
    {ASM330LHH_REG_INT_DUR2,           &int_dur2_t.buf},
    {ASM330LHH_REG_WAKE_UP_THS,        &wake_up_ths_t.buf},
    {ASM330LHH_REG_WAKE_UP_DUR,        &wake_up_dur_t.buf},
    {ASM330LHH_REG_FREE_FALL,          &free_fall_t.buf},
    {ASM330LHH_REG_MD1_CFG,            &md1_cfg_t.buf},
    {ASM330LHH_REG_MD2_CFG,            &md2_cfg_t.buf},
    {ASM330LHH_REG_INTERNAL_FREQ_FINE, &internal_freq_fine.buf},
    {ASM330LHH_REG_X_OFS_USR,          &x_ofs_usr.buf},
    {ASM330LHH_REG_Y_OFS_USR,          &y_ofs_usr.buf},
    {ASM330LHH_REG_Z_OFS_USR,          &z_ofs_usr.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_TAG,  &fifo_data_out_tag.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_X_L,  &fifo_data_out_x_l.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_X_H,  &fifo_data_out_x_h.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_Y_L,  &fifo_data_out_y_l.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_Y_H,  &fifo_data_out_y_h.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_Z_L,  &fifo_data_out_z_l.buf},
    {ASM330LHH_REG_FIFO_DATA_OUT_Z_H,  &fifo_data_out_z_h.buf},
};

It was quite painful to find each macro and copy-paste every single one.

Also in my opinion having all of the register addresses together will help to check if addresses are correct, And edit, like for example I added prefix REG after prefix ASM330LHH. Well I edited that using find/replace function but, still when all of them are in one place I could use find/replace in selected text only instead of being extra careful and find/replace one by one so that I won't make mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant