Skip to content

Commit

Permalink
ports/psoc6: Replaced deprecated STATIC macro.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx authored and actions-user committed Mar 17, 2024
1 parent b370365 commit 5af922f
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 212 deletions.
2 changes: 1 addition & 1 deletion ports/psoc6/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def parse_board_file(self):

def print_named(self, label, named_pins):
print(
"STATIC const mp_rom_map_elem_t pin_{:s}_pins_locals_dict_table[] = {{".format(label)
"static const mp_rom_map_elem_t pin_{:s}_pins_locals_dict_table[] = {{".format(label)
)
num_cpu_pins = 0
for named_pin in named_pins:
Expand Down
24 changes: 12 additions & 12 deletions ports/psoc6/machine_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ uint8_t adc_get_resolution(machine_adc_obj_t *adc) {
}

// machine_adc_print()
STATIC void machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<ADC Pin=%u, ADCBlock_id=%d, sampling_time_ns=%ld>", self->pin_phy->addr, self->block->id, self->sample_ns);
}

// ADC(id)
STATIC mp_obj_t machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static mp_obj_t machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
// Check number of arguments
mp_arg_check_num(n_args, n_kw, 1, 6, true);
enum {ARG_sample_ns};
Expand All @@ -99,46 +99,46 @@ STATIC mp_obj_t machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, s
}

// deinit()
STATIC mp_obj_t machine_adc_deinit(mp_obj_t self_in) {
static mp_obj_t machine_adc_deinit(mp_obj_t self_in) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
adc_obj_deinit(self);
adc_block_channel_free(self->block, self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_deinit_obj, machine_adc_deinit);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_deinit_obj, machine_adc_deinit);

// block()
STATIC mp_obj_t machine_adc_block(mp_obj_t self_in) {
static mp_obj_t machine_adc_block(mp_obj_t self_in) {
const machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_FROM_PTR(self->block);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_block_obj, machine_adc_block);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_block_obj, machine_adc_block);

// read_u16()
STATIC mp_obj_t machine_adc_read_u16(mp_obj_t self_in) {
static mp_obj_t machine_adc_read_u16(mp_obj_t self_in) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
int32_t adc_raw_result = cyhal_adc_read(&(self->adc_chan_obj));
mp_int_t bits = (mp_int_t)adc_get_resolution(self);
mp_uint_t u16 = adc_raw_result << (16 - bits);
return MP_OBJ_NEW_SMALL_INT(u16);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_u16_obj, machine_adc_read_u16);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_u16_obj, machine_adc_read_u16);

// read_uv
STATIC mp_obj_t machine_adc_read_uv(mp_obj_t self_in) {
static mp_obj_t machine_adc_read_uv(mp_obj_t self_in) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_NEW_SMALL_INT(cyhal_adc_read_uv(&(self->adc_chan_obj)));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_uv_obj, machine_adc_read_uv);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_uv_obj, machine_adc_read_uv);


STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_adc_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_read_u16), MP_ROM_PTR(&machine_adc_read_u16_obj) },
{ MP_ROM_QSTR(MP_QSTR_read_uv), MP_ROM_PTR(&machine_adc_read_uv_obj) },
{ MP_ROM_QSTR(MP_QSTR_block), MP_ROM_PTR(&machine_adc_block_obj) },
};
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);

MP_DEFINE_CONST_OBJ_TYPE(
machine_adc_type,
Expand Down
16 changes: 8 additions & 8 deletions ports/psoc6/machine_adcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ machine_adc_obj_t *adc_block_channel_find(machine_adcblock_obj_t *adc_block, mp_
}

// machine_adcblock_print()
STATIC void machine_adcblock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_adcblock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_adcblock_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "ADCBlock(%u, bits=%u)", self->id, self->bits);
}

// ADCBlock constructor
STATIC mp_obj_t machine_adcblock_make_new(const mp_obj_type_t *type, size_t n_pos_args, size_t n_kw_args, const mp_obj_t *all_args) {
static mp_obj_t machine_adcblock_make_new(const mp_obj_type_t *type, size_t n_pos_args, size_t n_kw_args, const mp_obj_t *all_args) {
mp_arg_check_num(n_pos_args, n_kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true);

mp_map_t kw_args;
Expand All @@ -251,16 +251,16 @@ STATIC mp_obj_t machine_adcblock_make_new(const mp_obj_type_t *type, size_t n_po
}

// ADCBlock deinit()
STATIC mp_obj_t machine_adcblock_deinit(mp_obj_t self_in) {
static mp_obj_t machine_adcblock_deinit(mp_obj_t self_in) {
machine_adcblock_obj_t *self = MP_OBJ_TO_PTR(self_in);
_adc_block_obj_deinit(self);
_adc_block_obj_free(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adcblock_deinit_obj, machine_adcblock_deinit);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adcblock_deinit_obj, machine_adcblock_deinit);

// ADCBlock connect()
STATIC mp_obj_t machine_adcblock_connect(size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t machine_adcblock_connect(size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
machine_adcblock_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
uint8_t channel = -1;
uint32_t pin = 0;
Expand Down Expand Up @@ -296,13 +296,13 @@ STATIC mp_obj_t machine_adcblock_connect(size_t n_pos_args, const mp_obj_t *pos_

return adc;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_adcblock_connect_obj, 2, machine_adcblock_connect);
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_adcblock_connect_obj, 2, machine_adcblock_connect);

STATIC const mp_rom_map_elem_t machine_adcblock_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_adcblock_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_adcblock_deinit_obj)},
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&machine_adcblock_connect_obj) },
};
STATIC MP_DEFINE_CONST_DICT(machine_adcblock_locals_dict, machine_adcblock_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_adcblock_locals_dict, machine_adcblock_locals_dict_table);

MP_DEFINE_CONST_OBJ_TYPE(
machine_adcblock_type,
Expand Down
40 changes: 20 additions & 20 deletions ports/psoc6/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static inline void i2c_obj_free(machine_i2c_obj_t *i2c_obj_ptr) {
}
}

STATIC void i2c_init(machine_i2c_obj_t *machine_i2c_obj, uint32_t freq_hz, int16_t slave_addr) {
static void i2c_init(machine_i2c_obj_t *machine_i2c_obj, uint32_t freq_hz, int16_t slave_addr) {
// Define the I2C master configuration structure

// Set cgf frequency
Expand All @@ -88,7 +88,7 @@ STATIC void i2c_init(machine_i2c_obj_t *machine_i2c_obj, uint32_t freq_hz, int16
i2c_assert_raise_val("I2C initialisation failed with return code %lx !", result);
}

STATIC inline void i2c_sda_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name) {
static inline void i2c_sda_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name) {
machine_pin_phy_obj_t *sda = pin_phy_realloc(pin_name, PIN_PHY_FUNC_I2C);

if (sda == NULL) {
Expand All @@ -99,11 +99,11 @@ STATIC inline void i2c_sda_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name)
i2c_obj->sda = sda;
}

STATIC inline void i2c_sda_free(machine_i2c_obj_t *i2c_obj) {
static inline void i2c_sda_free(machine_i2c_obj_t *i2c_obj) {
pin_phy_free(i2c_obj->sda);
}

STATIC inline void i2c_scl_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name) {
static inline void i2c_scl_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name) {
machine_pin_phy_obj_t *scl = pin_phy_realloc(pin_name, PIN_PHY_FUNC_I2C);

if (scl == NULL) {
Expand All @@ -114,11 +114,11 @@ STATIC inline void i2c_scl_alloc(machine_i2c_obj_t *i2c_obj, mp_obj_t pin_name)
i2c_obj->scl = scl;
}

STATIC inline void i2c_scl_free(machine_i2c_obj_t *i2c_obj) {
static inline void i2c_scl_free(machine_i2c_obj_t *i2c_obj) {
pin_phy_free(i2c_obj->scl);
}

STATIC void machine_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "I2C(freq=%u, scl=%u, sda=%u, mode=%u, addr=%u)", self->cfg.frequencyhal_hz, self->scl->addr, self->sda->addr, self->cfg.is_slave, self->cfg.address);
}
Expand Down Expand Up @@ -184,15 +184,15 @@ mp_obj_t machine_i2c_slave_make_new(const mp_obj_type_t *type, size_t n_args, si
return MP_OBJ_FROM_PTR(self);
}

STATIC void machine_i2c_deinit(mp_obj_base_t *self_in) {
static void machine_i2c_deinit(mp_obj_base_t *self_in) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
cyhal_i2c_free(&(self->i2c_obj));
i2c_sda_free(self);
i2c_scl_free(self);
i2c_obj_free(self);
}

STATIC int machine_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, size_t len, uint8_t *buf, unsigned int flags) {
static int machine_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, size_t len, uint8_t *buf, unsigned int flags) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
cy_rslt_t result = CY_RSLT_SUCCESS;
bool send_stop = (flags & MP_MACHINE_I2C_FLAG_STOP) ? true : false;
Expand Down Expand Up @@ -228,7 +228,7 @@ STATIC int machine_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, size_t le
}
}

STATIC const mp_machine_i2c_p_t machine_i2c_p = {
static const mp_machine_i2c_p_t machine_i2c_p = {
.deinit = machine_i2c_deinit,
.transfer_single = machine_i2c_transfer,
.transfer = mp_machine_i2c_transfer_adaptor
Expand All @@ -246,14 +246,14 @@ MP_DEFINE_CONST_OBJ_TYPE(

#if MICROPY_PY_MACHINE_I2C_SLAVE

STATIC mp_obj_t machine_i2c_slave_deinit(mp_obj_t self_in) {
static mp_obj_t machine_i2c_slave_deinit(mp_obj_t self_in) {
mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in);
machine_i2c_deinit(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_slave_deinit_obj, machine_i2c_slave_deinit);

STATIC mp_obj_t machine_i2c_slave_configure_receive_buffer(mp_obj_t self_in, mp_obj_t buf_in) {
static mp_obj_t machine_i2c_slave_configure_receive_buffer(mp_obj_t self_in, mp_obj_t buf_in) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
Expand All @@ -263,9 +263,9 @@ STATIC mp_obj_t machine_i2c_slave_configure_receive_buffer(mp_obj_t self_in, mp_

return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_slave_conf_rx_buffer_obj, machine_i2c_slave_configure_receive_buffer);
static MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_slave_conf_rx_buffer_obj, machine_i2c_slave_configure_receive_buffer);

STATIC mp_obj_t machine_i2c_slave_configure_transmit_buffer(mp_obj_t self_in, mp_obj_t buf_in) {
static mp_obj_t machine_i2c_slave_configure_transmit_buffer(mp_obj_t self_in, mp_obj_t buf_in) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
Expand All @@ -275,14 +275,14 @@ STATIC mp_obj_t machine_i2c_slave_configure_transmit_buffer(mp_obj_t self_in, mp

return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_slave_conf_tx_buffer_obj, machine_i2c_slave_configure_transmit_buffer);
static MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_slave_conf_tx_buffer_obj, machine_i2c_slave_configure_transmit_buffer);

static void i2c_irq_handler(void *callback_arg, cyhal_i2c_event_t event) {
machine_i2c_obj_t *self = callback_arg;
mp_sched_schedule(self->callback, mp_obj_new_int(event));
}

STATIC mp_obj_t machine_i2c_slave_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t machine_i2c_slave_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_callback, ARG_events, ARG_priority};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_callback, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
Expand All @@ -301,16 +301,16 @@ STATIC mp_obj_t machine_i2c_slave_irq(size_t n_args, const mp_obj_t *pos_args, m

return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_slave_irq_obj, 1, machine_i2c_slave_irq);
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_slave_irq_obj, 1, machine_i2c_slave_irq);

STATIC mp_obj_t machine_i2c_slave_irq_disable(mp_obj_t self_in) {
static mp_obj_t machine_i2c_slave_irq_disable(mp_obj_t self_in) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
cyhal_i2c_enable_event(&self->i2c_obj, CYHAL_I2C_EVENT_NONE, 3, false);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_slave_irq_disable_obj, machine_i2c_slave_irq_disable);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_slave_irq_disable_obj, machine_i2c_slave_irq_disable);

STATIC const mp_rom_map_elem_t machine_i2c_slave_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_i2c_slave_locals_dict_table[] = {
// Functions
{ MP_ROM_QSTR(MP_QSTR_conf_receive_buffer), MP_ROM_PTR(&machine_i2c_slave_conf_rx_buffer_obj) },
{ MP_ROM_QSTR(MP_QSTR_conf_transmit_buffer), MP_ROM_PTR(&machine_i2c_slave_conf_tx_buffer_obj) },
Expand All @@ -327,7 +327,7 @@ STATIC const mp_rom_map_elem_t machine_i2c_slave_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_WR_CMPLT_EVENT), MP_ROM_INT(CYHAL_I2C_SLAVE_WR_CMPLT_EVENT) },
{ MP_ROM_QSTR(MP_QSTR_ERR_EVENT), MP_ROM_INT(CYHAL_I2C_SLAVE_ERR_EVENT) },
};
STATIC MP_DEFINE_CONST_DICT(machine_i2c_slave_locals_dict, machine_i2c_slave_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_i2c_slave_locals_dict, machine_i2c_slave_locals_dict_table);

MP_DEFINE_CONST_OBJ_TYPE(
machine_i2c_slave_type,
Expand Down
Loading

0 comments on commit 5af922f

Please sign in to comment.