diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-06-26 10:58:54 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-06-26 11:50:42 -0500 |
| commit | f496c0b58d63f594ce42bd5b34cf8421674b4108 (patch) | |
| tree | f9db3d3e9db51a6a08ef9cabdff1c5e55c550eec /tools | |
| parent | d4b945851285c0b5d3a38094223d97184449e7e1 (diff) | |
atmel-samd: Add SDIO SD card interface
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/mksdiodata.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/mksdiodata.py b/tools/mksdiodata.py new file mode 100755 index 000000000..0cce3819f --- /dev/null +++ b/tools/mksdiodata.py @@ -0,0 +1,40 @@ +#!/usr/bin/python3 + +def defines(name, function): + print(f'pin_function_t {name} [] = {{') + for instance in (0, 1): + for port in 'ABCD': + for idx in range(32): + pin = f'P{port}{idx:02d}' + pinmux = f'PINMUX_{pin}I_SDHC{instance}_{function}' + print(f'''\ +#if defined({pinmux}) && ! defined(IGNORE_PIN_{pin}) + {{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}}, +#endif''') + print(f'{{NULL, 0, 0}}') + print(f'}};') + print() + +print('''\ +#include <stdint.h> +#include "py/obj.h" +#include "sam.h" +#include "samd/pins.h" +#include "mpconfigport.h" +#include "atmel_start_pins.h" +#include "hal/include/hal_gpio.h" + +typedef struct { + const mcu_pin_obj_t *obj; + uint8_t instance; + uint8_t pin; + uint16_t function; +} pin_function_t; +''') + +defines('sdio_ck', 'SDCK') +defines('sdio_cmd', 'SDCMD') +defines('sdio_dat0', 'SDDAT0') +defines('sdio_dat1', 'SDDAT1') +defines('sdio_dat2', 'SDDAT2') +defines('sdio_dat3', 'SDDAT3') |
