Commit 1f804e03 authored by Jim Mussared's avatar Jim Mussared Committed by Damien George

renesas-ra/boards/make-pins.py: Update to use tools/boardgen.py.

This removes previously unused functionality to generate pins_ad_const.h,
as well as the unused handling of pin AF in machine_pin.c.

This work was funded through GitHub Sponsors.
Signed-off-by: default avatarJim Mussared <jim.mussared@gmail.com>
parent c0b64a3f
......@@ -556,8 +556,6 @@ AF_FILE = boards/ra6m5_af.csv
endif
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
# Currently unused.
GEN_PINS_AD_CONST = $(HEADER_BUILD)/pins_ad_const.h
FILE2H = $(TOP)/tools/file2h.py
......@@ -578,10 +576,10 @@ $(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h
# Use a pattern rule here so that make will only call make-pins.py once to make
# both pins_$(BOARD).c and pins.h
.PRECIOUS: $(GEN_PINS_SRC)
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_ad_const.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(MAKE_PINS) --board-csv $(BOARD_PINS) --af-csv $(AF_FILE) --prefix $(PREFIX_FILE) \
--output-source $(GEN_PINS_SRC) --output-header $(GEN_PINS_HDR) --output-ad-const $(GEN_PINS_AD_CONST)
--output-source $(GEN_PINS_SRC) --output-header $(GEN_PINS_HDR)
CMSIS_MCU_HDR = $(CMSIS_DIR)/$(CMSIS_MCU_LOWER).h
......
This diff is collapsed.
......@@ -7,19 +7,19 @@
#include "extmod/modmachine.h"
#include "pin.h"
#define PIN_AD(p_name, p_pin, ad_bit, ad_channel) \
#define PIN_ADC(p_name, p_pin, adc_bits, adc_channel) \
{ \
{ &machine_pin_type }, \
.name = MP_QSTR_##p_name, \
.pin = p_pin, \
.bit = ad_bit, \
.channel = ad_channel \
.bit = adc_bits, \
.channel = adc_channel \
}
#define PIN(p_name, p_pin, p_ad) \
#define PIN(p_name, p_pin, p_adc) \
{ \
{ &machine_pin_type }, \
.name = MP_QSTR_##p_name, \
.pin = p_pin, \
.ad = p_ad, \
.ad = p_adc, \
}
......@@ -56,13 +56,13 @@ const machine_pin_obj_t *machine_pin_find(mp_obj_t user_obj) {
}
// See if the pin name matches a board pin
pin_obj = pin_find_named_pin(&pin_board_pins_locals_dict, user_obj);
pin_obj = pin_find_named_pin(&machine_pin_board_pins_locals_dict, user_obj);
if (pin_obj) {
return pin_obj;
}
// See if the pin name matches a cpu pin
pin_obj = pin_find_named_pin(&pin_cpu_pins_locals_dict, user_obj);
pin_obj = pin_find_named_pin(&machine_pin_cpu_pins_locals_dict, user_obj);
if (pin_obj) {
return pin_obj;
}
......@@ -134,12 +134,7 @@ STATIC void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_prin
// AF mode
if (af) {
mp_uint_t af_idx = pin_get_af(self);
const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx);
if (af_obj == NULL) {
mp_printf(print, ", alt=%d)", af_idx);
} else {
mp_printf(print, ", alt=Pin.%q)", af_obj->name);
}
mp_printf(print, ", alt=%d)", af_idx);
} else {
mp_print_str(print, ")");
}
......@@ -306,8 +301,8 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_high), MP_ROM_PTR(&machine_pin_high_obj) },
// class attributes
{ MP_ROM_QSTR(MP_QSTR_board), MP_ROM_PTR(&pin_board_pins_obj_type) },
{ MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&pin_cpu_pins_obj_type) },
{ MP_ROM_QSTR(MP_QSTR_board), MP_ROM_PTR(&machine_pin_board_pins_obj_type) },
{ MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&machine_pin_cpu_pins_obj_type) },
// class constants
{ MP_ROM_QSTR(MP_QSTR_IN), MP_ROM_INT(MP_HAL_PIN_MODE_INPUT) },
......@@ -391,17 +386,17 @@ uint32_t pin_get_af(const machine_pin_obj_t *pin) {
}
MP_DEFINE_CONST_OBJ_TYPE(
pin_cpu_pins_obj_type,
machine_pin_cpu_pins_obj_type,
MP_QSTR_cpu,
MP_TYPE_FLAG_NONE,
locals_dict, &pin_cpu_pins_locals_dict
locals_dict, &machine_pin_cpu_pins_locals_dict
);
MP_DEFINE_CONST_OBJ_TYPE(
pin_board_pins_obj_type,
machine_pin_board_pins_obj_type,
MP_QSTR_board,
MP_TYPE_FLAG_NONE,
locals_dict, &pin_board_pins_locals_dict
locals_dict, &machine_pin_board_pins_locals_dict
);
const machine_pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name) {
......@@ -412,13 +407,3 @@ const machine_pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_
}
return NULL;
}
const pin_af_obj_t *pin_find_af_by_index(const machine_pin_obj_t *pin, mp_uint_t af_idx) {
const pin_af_obj_t *af = pin->af;
for (mp_uint_t i = 0; i < pin->num_af; i++, af++) {
if (af->idx == af_idx) {
return af;
}
}
return NULL;
}
......@@ -31,57 +31,29 @@
#include "shared/runtime/mpirq.h"
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
qstr name;
uint8_t idx;
uint8_t fn;
uint8_t unit;
uint8_t type;
void *reg; // The peripheral associated with this AF
} pin_af_obj_t;
typedef struct {
mp_obj_base_t base;
qstr name;
uint8_t pin;
uint8_t bit;
uint8_t channel;
} pin_ad_obj_t;
} machine_pin_adc_obj_t;
typedef struct {
mp_obj_base_t base;
qstr name;
uint8_t pin;
uint8_t num_af;
const pin_af_obj_t *af;
const pin_ad_obj_t *ad;
const machine_pin_adc_obj_t *ad;
} machine_pin_obj_t;
extern const mp_obj_type_t pin_af_type;
// Include all of the individual pin objects
#include "genhdr/pins.h"
typedef struct {
const char *name;
const machine_pin_obj_t *pin;
} pin_named_pin_t;
extern const pin_named_pin_t pin_board_pins[];
extern const pin_named_pin_t pin_cpu_pins[];
typedef struct {
mp_obj_base_t base;
qstr name;
const pin_named_pin_t *named_pins;
} pin_named_pins_obj_t;
extern const mp_obj_type_t pin_board_pins_obj_type;
extern const mp_obj_type_t pin_cpu_pins_obj_type;
extern const mp_obj_type_t machine_pin_board_pins_obj_type;
extern const mp_obj_type_t machine_pin_cpu_pins_obj_type;
extern const mp_obj_dict_t pin_cpu_pins_locals_dict;
extern const mp_obj_dict_t pin_board_pins_locals_dict;
extern const mp_obj_dict_t machine_pin_cpu_pins_locals_dict;
extern const mp_obj_dict_t machine_pin_board_pins_locals_dict;
void machine_pin_init(void);
uint32_t pin_get_mode(const machine_pin_obj_t *pin);
......@@ -90,8 +62,5 @@ uint32_t pin_get_drive(const machine_pin_obj_t *pin);
uint32_t pin_get_af(const machine_pin_obj_t *pin);
const machine_pin_obj_t *machine_pin_find(mp_obj_t user_obj);
const machine_pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name);
const pin_af_obj_t *pin_find_af(const machine_pin_obj_t *pin, uint8_t fn, uint8_t unit);
const pin_af_obj_t *pin_find_af_by_index(const machine_pin_obj_t *pin, mp_uint_t af_idx);
const pin_af_obj_t *pin_find_af_by_name(const machine_pin_obj_t *pin, const char *name);
#endif // MICROPY_INCLUDED_RA_PIN_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment