samd/boards: Replace pins.c and pins.h by pins.csv.

The files pins.c and pins.h are generated during the build process from
pins.csv, using a make-pins.py script.
This commit is contained in:
robert-hh 2022-05-27 21:19:47 +02:00 committed by Damien George
parent 85afed569d
commit 0420799a84
23 changed files with 367 additions and 715 deletions

View File

@ -56,6 +56,11 @@ LDFLAGS += $(LDFLAGS_MOD)
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
MAKE_PINS = boards/make-pins.py
BOARD_PINS = $(BOARD_DIR)/pins.csv
GEN_PINS_SRC = $(BUILD)/pins.c
GEN_PINS_HDR = $(BUILD)/pins.h
# Tune for Debugging or Optimization
CFLAGS += -g # always include debug info in the ELF
ifeq ($(DEBUG),1)
@ -79,7 +84,7 @@ SRC_C = \
help.c \
modutime.c \
modmachine.c \
$(BOARD_DIR)/pins.c \
$(BUILD)/pins.c \
machine_pin.c \
machine_led.c \
modsamd.c \
@ -160,4 +165,8 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
$(Q)$(PYTHON) $(UF2CONV) -b $(TEXT0) -c -o $@ $<
$(GEN_PINS_SRC): $(BOARD_PINS)
$(ECHO) "Create $@"
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --pins $(GEN_PINS_SRC) --inc $(GEN_PINS_HDR)
include $(TOP)/py/mkrules.mk

View File

@ -1,59 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PA11}, // D0
{{&machine_pin_type}, PIN_PA10}, // D1
{{&machine_pin_type}, PIN_PA14}, // D2
{{&machine_pin_type}, PIN_PA09}, // D3/
{{&machine_pin_type}, PIN_PA08}, // D4/
{{&machine_pin_type}, PIN_PA15}, // D5
{{&machine_pin_type}, PIN_PA20}, // D6
{{&machine_pin_type}, PIN_PA21}, // D7
{{&machine_pin_type}, PIN_PA06}, // D8/
{{&machine_pin_type}, PIN_PA07}, // D9/
{{&machine_pin_type}, PIN_PA18}, // D10
{{&machine_pin_type}, PIN_PA16}, // D11
{{&machine_pin_type}, PIN_PA19}, // D12
{{&machine_pin_type}, PIN_PA17}, // D13/
{{&machine_pin_type}, PIN_PA02}, // A0
{{&machine_pin_type}, PIN_PB08}, // A1
{{&machine_pin_type}, PIN_PB09}, // A2
{{&machine_pin_type}, PIN_PA04}, // A3/
{{&machine_pin_type}, PIN_PA05}, // A4/
{{&machine_pin_type}, PIN_PB02}, // A5
};
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PA17}, // D13/ user LED
};

View File

@ -0,0 +1,37 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PA11,D0
PIN_PA10,D1
PIN_PA14,D2
PIN_PA09,D3
PIN_PA08,D4
PIN_PA15,D5
PIN_PA20,D6
PIN_PA21,D7
PIN_PA06,D8
PIN_PA07,D9
PIN_PA18,D10
PIN_PA16,D11
PIN_PA19,D12
PIN_PA17,D13
PIN_PA02,A0
PIN_PB08,A1
PIN_PB09,A2
PIN_PA04,A3
PIN_PA05,A4
PIN_PB02,A5
PIN_PB22,TX
PIN_PB23,RX
PIN_PA23,SCL
PIN_PA22,SDA
PIN_PA06,NEOPIXEL
PIN_PA13,FLASH_CS
LED_PA17,LED
LED_PA27,LED_TX
LED_PB03,LED_RX
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PA11,D0
8 PIN_PA10,D1
9 PIN_PA14,D2
10 PIN_PA09,D3
11 PIN_PA08,D4
12 PIN_PA15,D5
13 PIN_PA20,D6
14 PIN_PA21,D7
15 PIN_PA06,D8
16 PIN_PA07,D9
17 PIN_PA18,D10
18 PIN_PA16,D11
19 PIN_PA19,D12
20 PIN_PA17,D13
21 PIN_PA02,A0
22 PIN_PB08,A1
23 PIN_PB09,A2
24 PIN_PA04,A3
25 PIN_PA05,A4
26 PIN_PB02,A5
27 PIN_PB22,TX
28 PIN_PB23,RX
29 PIN_PA23,SCL
30 PIN_PA22,SDA
31 PIN_PA06,NEOPIXEL
32 PIN_PA13,FLASH_CS
33 LED_PA17,LED
34 LED_PA27,LED_TX
35 LED_PB03,LED_RX

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[20];
extern const machine_led_obj_t machine_led_obj[1];

View File

@ -1,59 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PA16}, // RX_D0
{{&machine_pin_type}, PIN_PA17}, // TX_D1
{{&machine_pin_type}, PIN_PA07}, // D2
{{&machine_pin_type}, PIN_PB22}, // D3
{{&machine_pin_type}, PIN_PA14}, // D4
{{&machine_pin_type}, PIN_PA15}, // D5
{{NULL}, -1}, // D6- not terminated on breakout.
{{&machine_pin_type}, PIN_PA18}, // D7
{{NULL}, -1}, // D8- not terminated on breakout.
{{&machine_pin_type}, PIN_PA19}, // D9
{{&machine_pin_type}, PIN_PA20}, // D10
{{&machine_pin_type}, PIN_PA21}, // D11
{{&machine_pin_type}, PIN_PA23}, // D12
{{&machine_pin_type}, PIN_PA22}, // D13
{{&machine_pin_type}, PIN_PA02}, // A0
{{&machine_pin_type}, PIN_PA05}, // A1
{{&machine_pin_type}, PIN_PB08}, // A2
{{&machine_pin_type}, PIN_PB09}, // A3
{{&machine_pin_type}, PIN_PA04}, // A4
{{&machine_pin_type}, PIN_PA06}, // A5
};
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PA22}, // D13
};

View File

@ -0,0 +1,36 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PA16,D0
PIN_PA17,D1
PIN_PA07,D2
PIN_PB22,D3
PIN_PA14,D4
PIN_PA15,D5
-
PIN_PA18,D7
-
PIN_PA19,D9
PIN_PA20,D10
PIN_PA21,D11
PIN_PA23,D12
PIN_PA22,D13
PIN_PA02,A0
PIN_PA05,A1
PIN_PB08,A2
PIN_PB09,A3
PIN_PA04,A4
PIN_PA06,A5
PIN_PA12,SDA
PIN_PA13,SCL
PIN_PA00,MO
PIN_PB23,MI
PIN_PA01,SCK
PIN_PB02,DOTSTAR_CLK
PIN_PB03,DOTSTAR_DATA
LED_PA22,LED
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PA16,D0
8 PIN_PA17,D1
9 PIN_PA07,D2
10 PIN_PB22,D3
11 PIN_PA14,D4
12 PIN_PA15,D5
13 -
14 PIN_PA18,D7
15 -
16 PIN_PA19,D9
17 PIN_PA20,D10
18 PIN_PA21,D11
19 PIN_PA23,D12
20 PIN_PA22,D13
21 PIN_PA02,A0
22 PIN_PA05,A1
23 PIN_PB08,A2
24 PIN_PB09,A3
25 PIN_PA04,A4
26 PIN_PA06,A5
27 PIN_PA12,SDA
28 PIN_PA13,SCL
29 PIN_PA00,MO
30 PIN_PB23,MI
31 PIN_PA01,SCK
32 PIN_PB02,DOTSTAR_CLK
33 PIN_PB03,DOTSTAR_DATA
34 LED_PA22,LED

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[20];
extern const machine_led_obj_t machine_led_obj[1];

View File

@ -1,44 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PA08}, // D0
{{&machine_pin_type}, PIN_PA02}, // D1
{{&machine_pin_type}, PIN_PA09}, // D2
{{&machine_pin_type}, PIN_PA07}, // D3/ RxD
{{&machine_pin_type}, PIN_PA06}, // D4/ TxD
};
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PA10}, // user LED
};

View File

@ -0,0 +1,16 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PA08,D0
PIN_PA02,D1
PIN_PA09,D2
PIN_PA07,D3
PIN_PA06,D4
PIN_PA00,DOTSTAR_DATA
PIN_PA01,DOTSTAR_CLK
LED_PA10,LED
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PA08,D0
8 PIN_PA02,D1
9 PIN_PA09,D2
10 PIN_PA07,D3
11 PIN_PA06,D4
12 PIN_PA00,DOTSTAR_DATA
13 PIN_PA01,DOTSTAR_CLK
14 LED_PA10,LED

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[5];
extern const machine_led_obj_t machine_led_obj[1];

View File

@ -1,52 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PA02}, // A0,D9
{{&machine_pin_type}, PIN_PB08}, // A1,D10
{{&machine_pin_type}, PIN_PB09}, // A2,D11
{{&machine_pin_type}, PIN_PA04}, // A3,D12
{{&machine_pin_type}, PIN_PA05}, // A4,D13
{{&machine_pin_type}, PIN_PA06}, // A5
{{&machine_pin_type}, PIN_PA16}, // RX_D0
{{&machine_pin_type}, PIN_PA17}, // TX_D1
{{&machine_pin_type}, PIN_PA07}, // D2,A6
{{&machine_pin_type}, PIN_PA19}, // D3
{{&machine_pin_type}, PIN_PA20}, // D4
{{&machine_pin_type}, PIN_PA21}, // D5
{{&machine_pin_type}, PIN_PA00}, // BUTTON
};
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PA15}, // LED
};

View File

@ -0,0 +1,27 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PA02,A0_D9
PIN_PB08,A1_D10
PIN_PB09,A2_D11
PIN_PA04,A3_D12
PIN_PA05,A4_D13
PIN_PA06,A5
PIN_PA16,D0
PIN_PA17,D1
PIN_PA07,A6_D2
PIN_PA19,D3
PIN_PA20,D4
PIN_PA21,D5
PIN_PA00,BUTTON
PIN_PA03,AREF
PIN_PA12,SDA
PIN_PA13,SCL
PIN_PB03,DOTSTAR_DATA
PIN_PB02,DOTSTAR_CLK
LED_PA15,LED
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PA02,A0_D9
8 PIN_PB08,A1_D10
9 PIN_PB09,A2_D11
10 PIN_PA04,A3_D12
11 PIN_PA05,A4_D13
12 PIN_PA06,A5
13 PIN_PA16,D0
14 PIN_PA17,D1
15 PIN_PA07,A6_D2
16 PIN_PA19,D3
17 PIN_PA20,D4
18 PIN_PA21,D5
19 PIN_PA00,BUTTON
20 PIN_PA03,AREF
21 PIN_PA12,SDA
22 PIN_PA13,SCL
23 PIN_PB03,DOTSTAR_DATA
24 PIN_PB02,DOTSTAR_CLK
25 LED_PA15,LED

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[13];
extern const machine_led_obj_t machine_led_obj[1];

View File

@ -1,92 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
// EXT1
{{&machine_pin_type}, PIN_PB00}, // PIN3_ADC(+)
{{&machine_pin_type}, PIN_PB01}, // PIN4_ADC(-)
{{&machine_pin_type}, PIN_PB06}, // PIN5_GPIO
{{&machine_pin_type}, PIN_PB07}, // PIN6_GPIO
{{&machine_pin_type}, PIN_PB02}, // PIN7_PWM(+)
{{&machine_pin_type}, PIN_PB03}, // PIN8_PWM(-)
{{&machine_pin_type}, PIN_PB04}, // PIN9_IRQ/GPIO
{{&machine_pin_type}, PIN_PB05}, // PIN10_SPI_SS_B/GPIO
{{&machine_pin_type}, PIN_PA08}, // PIN11_TWI_SDA
{{&machine_pin_type}, PIN_PA09}, // PIN12_TWI_SCL
{{&machine_pin_type}, PIN_PB09}, // PIN13_UART_RX
{{&machine_pin_type}, PIN_PB08}, // PIN14_UART_TX
{{&machine_pin_type}, PIN_PA05}, // PIN15_SPI_SS_A
{{&machine_pin_type}, PIN_PA06}, // PIN16_SPI_MOSI
{{&machine_pin_type}, PIN_PA04}, // PIN17_SPI_MISO
{{&machine_pin_type}, PIN_PA07}, // PIN18_SPI_SCK
// EXT2
{{&machine_pin_type}, PIN_PA10}, // PIN3_ADC(+)
{{&machine_pin_type}, PIN_PA11}, // PIN4_ADC(-)
{{&machine_pin_type}, PIN_PA20}, // PIN5_GPIO
{{&machine_pin_type}, PIN_PA21}, // PIN6_GPIO
{{&machine_pin_type}, PIN_PB12}, // PIN7_PWM(+)
{{&machine_pin_type}, PIN_PB13}, // PIN8_PWM(-)
{{&machine_pin_type}, PIN_PB14}, // PIN9_IRQ/GPIO
{{&machine_pin_type}, PIN_PB15}, // PIN10_SPI_SS_B/GPIO
{{NULL}, -1}, // PIN_PA08/ PIN11_TWI_SDA already defined
{{NULL}, -1}, // PIN_PA09/ PIN12_TWI_SCL already defined
{{&machine_pin_type}, PIN_PB11}, // PIN13_UART_RX
{{&machine_pin_type}, PIN_PB10}, // PIN14_UART_TX
{{&machine_pin_type}, PIN_PA17}, // PIN15_SPI_SS_A
{{&machine_pin_type}, PIN_PA18}, // PIN16_SPI_MOSI
{{&machine_pin_type}, PIN_PA16}, // PIN17_SPI_MISO
{{&machine_pin_type}, PIN_PA19}, // PIN18_SPI_SCK
// EXT3
{{&machine_pin_type}, PIN_PA02}, // PIN3_ADC(+)
{{&machine_pin_type}, PIN_PA03}, // PIN4_ADC(-)
{{NULL}, -1}, // PIN_PB30/ PIN5_GPIO already defined
{{&machine_pin_type}, PIN_PA15}, // PIN6_GPIO; USER_BUTTON
{{&machine_pin_type}, PIN_PA12}, // PIN7_PWM(+)
{{&machine_pin_type}, PIN_PA13}, // PIN8_PWM(-)
{{&machine_pin_type}, PIN_PA28}, // PIN9_IRQ/GPIO
{{&machine_pin_type}, PIN_PA27}, // PIN10_SPI_SS_B/GPIO
{{NULL}, -1}, // PIN_PA08/ PIN11_TWI_SDA already defined
{{NULL}, -1}, // PIN_PA09/ PIN12_TWI_SCL already defined
{{NULL}, -1}, // PIN_PB11/ PIN13_UART_RX already defined
{{NULL}, -1}, // PIN_PB10/ PIN14_UART_TX already defined
{{&machine_pin_type}, PIN_PB17}, // PIN15_SPI_SS_A
{{&machine_pin_type}, PIN_PB22}, // PIN16_SPI_MOSI
{{&machine_pin_type}, PIN_PB16}, // PIN17_SPI_MISO
{{&machine_pin_type}, PIN_PB23}, // PIN18_SPI_SCK
};
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PB30}, // USER_LED
};

View File

@ -0,0 +1,63 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
# EXT1
PIN_PB00,EXT1_PIN3
PIN_PB01,EXT1_PIN4
PIN_PB06,EXT1_PIN5
PIN_PB07,EXT1_PIN6
PIN_PB02,EXT1_PIN7
PIN_PB03,EXT1_PIN8
PIN_PB04,EXT1_PIN9
PIN_PB05,EXT1_PIN10
PIN_PA08,EXT1_PIN11
PIN_PA09,EXT1_PIN12
PIN_PB09,EXT1_PIN13
PIN_PB08,EXT1_PIN14
PIN_PA05,EXT1_PIN15
PIN_PA06,EXT1_PIN16
PIN_PA04,EXT1_PIN17
PIN_PA07,EXT1_PIN18
# EXT2
PIN_PA10,EXT2_PIN3
PIN_PA11,EXT2_PIN4
PIN_PA20,EXT2_PIN5
PIN_PA21,EXT2_PIN6
PIN_PB12,EXT2_PIN7
PIN_PB13,EXT2_PIN8
PIN_PB14,EXT2_PIN9
PIN_PB15,EXT2_PIN10
-
-
PIN_PB11,EXT2_PIN13
PIN_PB10,EXT2_PIN14
PIN_PA17,EXT2_PIN15
PIN_PA18,EXT2_PIN16
PIN_PA16,EXT2_PIN17
PIN_PA19,EXT2_PIN18
# EXT3
PIN_PA02,EXT3_PIN3
PIN_PA03,EXT3_PIN4
-
PIN_PA15,EXT3_PIN6
PIN_PA12,EXT3_PIN7
PIN_PA13,EXT3_PIN8
PIN_PA28,EXT3_PIN9
PIN_PA27,EXT3_PIN10
-
-
-
-
PIN_PB17,EXT3_PIN15
PIN_PB22,EXT3_PIN16
PIN_PB16,EXT3_PIN17
PIN_PB23,EXT3_PIN18
LED_PB30,LED
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 # EXT1
8 PIN_PB00,EXT1_PIN3
9 PIN_PB01,EXT1_PIN4
10 PIN_PB06,EXT1_PIN5
11 PIN_PB07,EXT1_PIN6
12 PIN_PB02,EXT1_PIN7
13 PIN_PB03,EXT1_PIN8
14 PIN_PB04,EXT1_PIN9
15 PIN_PB05,EXT1_PIN10
16 PIN_PA08,EXT1_PIN11
17 PIN_PA09,EXT1_PIN12
18 PIN_PB09,EXT1_PIN13
19 PIN_PB08,EXT1_PIN14
20 PIN_PA05,EXT1_PIN15
21 PIN_PA06,EXT1_PIN16
22 PIN_PA04,EXT1_PIN17
23 PIN_PA07,EXT1_PIN18
24 # EXT2
25 PIN_PA10,EXT2_PIN3
26 PIN_PA11,EXT2_PIN4
27 PIN_PA20,EXT2_PIN5
28 PIN_PA21,EXT2_PIN6
29 PIN_PB12,EXT2_PIN7
30 PIN_PB13,EXT2_PIN8
31 PIN_PB14,EXT2_PIN9
32 PIN_PB15,EXT2_PIN10
33 -
34 -
35 PIN_PB11,EXT2_PIN13
36 PIN_PB10,EXT2_PIN14
37 PIN_PA17,EXT2_PIN15
38 PIN_PA18,EXT2_PIN16
39 PIN_PA16,EXT2_PIN17
40 PIN_PA19,EXT2_PIN18
41 # EXT3
42 PIN_PA02,EXT3_PIN3
43 PIN_PA03,EXT3_PIN4
44 -
45 PIN_PA15,EXT3_PIN6
46 PIN_PA12,EXT3_PIN7
47 PIN_PA13,EXT3_PIN8
48 PIN_PA28,EXT3_PIN9
49 PIN_PA27,EXT3_PIN10
50 -
51 -
52 -
53 -
54 PIN_PB17,EXT3_PIN15
55 PIN_PB22,EXT3_PIN16
56 PIN_PB16,EXT3_PIN17
57 PIN_PB23,EXT3_PIN18
58 LED_PB30,LED

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[48];
extern const machine_led_obj_t machine_led_obj[1];

View File

@ -1,61 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in "pins.h" reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PB08}, // A0/D0
{{&machine_pin_type}, PIN_PB09}, // A1/D1
{{&machine_pin_type}, PIN_PA07}, // A2/D2
{{&machine_pin_type}, PIN_PB04}, // A3/D3
{{&machine_pin_type}, PIN_PB05}, // A4/D4
{{&machine_pin_type}, PIN_PB06}, // A5/D5
{{&machine_pin_type}, PIN_PA04}, // A6/D6
{{&machine_pin_type}, PIN_PB07}, // A7/D7
{{&machine_pin_type}, PIN_PA06}, // A8/D8
{{&machine_pin_type}, PIN_PD08}, // SWITCH_X
{{&machine_pin_type}, PIN_PD09}, // SWITCH_Y
{{&machine_pin_type}, PIN_PD10}, // SWITCH_Z
{{&machine_pin_type}, PIN_PD12}, // SWITCH_B
{{&machine_pin_type}, PIN_PD20}, // SWITCH_U
{{&machine_pin_type}, PIN_PC26}, // BUTTON_1
{{&machine_pin_type}, PIN_PC27}, // BUTTON_2
{{&machine_pin_type}, PIN_PC28}, // BUTTON_3
{{&machine_pin_type}, PIN_PD11}, // BUZZER_CTR
{{&machine_pin_type}, PIN_PC14}, // 5V_OUTPUT_CTR- enable 5V on hdr
{{&machine_pin_type}, PIN_PC15}, // 3V3_OUTPUT_CTR- enable 3V3 on hdr
};
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_led_obj_t machine_led_obj[] = {
{{&machine_led_type}, PIN_PA15}, // USER_LED (Blue)
{{&machine_led_type}, PIN_PC05}, // LCD_BACKLIGHT_CTR
};

View File

@ -0,0 +1,30 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PB08,A0_D0
PIN_PB09,A1_D1
PIN_PA07,A2_D2
PIN_PB04,A3_D3
PIN_PB05,A4_D4
PIN_PB06,A5_D5
PIN_PA04,A6_D6
PIN_PB07,A7_D7
PIN_PA06,A8_D8
PIN_PD08,SWITCH_X
PIN_PD09,SWITCH_Y
PIN_PD10,SWITCH_Z
PIN_PD12,SWITCH_B
PIN_PD20,SWITCH_U
PIN_PC26,BUTTON_1
PIN_PC27,BUTTON_2
PIN_PC28,BUTTON_3
PIN_PD11,BUZZER_CTR
PIN_PC14,5V_ENABLE
PIN_PC15,3V3_ENABLE
LED_PA15,LED_BLUE
LED_PC05,LED_LCD
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PB08,A0_D0
8 PIN_PB09,A1_D1
9 PIN_PA07,A2_D2
10 PIN_PB04,A3_D3
11 PIN_PB05,A4_D4
12 PIN_PB06,A5_D5
13 PIN_PA04,A6_D6
14 PIN_PB07,A7_D7
15 PIN_PA06,A8_D8
16 PIN_PD08,SWITCH_X
17 PIN_PD09,SWITCH_Y
18 PIN_PD10,SWITCH_Z
19 PIN_PD12,SWITCH_B
20 PIN_PD20,SWITCH_U
21 PIN_PC26,BUTTON_1
22 PIN_PC27,BUTTON_2
23 PIN_PC28,BUTTON_3
24 PIN_PD11,BUZZER_CTR
25 PIN_PC14,5V_ENABLE
26 PIN_PC15,3V3_ENABLE
27 LED_PA15,LED_BLUE
28 LED_PC05,LED_LCD

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[20];
extern const machine_led_obj_t machine_led_obj[2];

View File

@ -1,53 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c. Holds Board/MCU specific Pin allocations.
*/
#include "modmachine.h"
#include "sam.h"
#include "pins.h"
// Ensure Declaration in 'pins.h' reflects # of Pins defined here.
const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, PIN_PA02}, // A0/D0
{{&machine_pin_type}, PIN_PA04}, // A1/D1
{{&machine_pin_type}, PIN_PA10}, // A2/D2
{{&machine_pin_type}, PIN_PA11}, // A3/D3
{{&machine_pin_type}, PIN_PA08}, // A4/D4
{{&machine_pin_type}, PIN_PA09}, // A5/D5
{{&machine_pin_type}, PIN_PB08}, // A6/D6
{{&machine_pin_type}, PIN_PB09}, // A7/D7
{{&machine_pin_type}, PIN_PA07}, // A8/D8
{{&machine_pin_type}, PIN_PA05}, // A9/D9
{{&machine_pin_type}, PIN_PA06}, // A10/D10
};
const machine_led_obj_t machine_led_obj[] = {
// XIAO: Just the available LED Pins: User LED (PA17), Rx & Tx.
{{&machine_led_type}, PIN_PA17}, // W13
{{&machine_led_type}, PIN_PA18}, // RX_LED
{{&machine_led_type}, PIN_PA19}, // TX_LED
};

View File

@ -0,0 +1,22 @@
# Pin rows contain Pin number and pin name.
# Pin rows start with PIN_
# LED rows start with LED_
# If the pin name is omitted, the pin number is added as name.
# Rows for empty entries have to start with '-'
# Empty lines and lines starting with # are ignored
PIN_PA02,A0_D0
PIN_PA04,A1_D1
PIN_PA10,A2_D2
PIN_PA11,A3_D3
PIN_PA08,A4_D4
PIN_PA09,A5_D5
PIN_PB08,A6_D6
PIN_PB09,A7_D7
PIN_PA07,A8_D8
PIN_PA05,A9_D9
PIN_PA06,A10_D10
LED_PA17,USER_LED
LED_PA18,RX_LED
LED_PA19,TX_LED
1 # Pin rows contain Pin number and pin name.
2 # Pin rows start with PIN_
3 # LED rows start with LED_
4 # If the pin name is omitted, the pin number is added as name.
5 # Rows for empty entries have to start with '-'
6 # Empty lines and lines starting with # are ignored
7 PIN_PA02,A0_D0
8 PIN_PA04,A1_D1
9 PIN_PA10,A2_D2
10 PIN_PA11,A3_D3
11 PIN_PA08,A4_D4
12 PIN_PA09,A5_D5
13 PIN_PB08,A6_D6
14 PIN_PB09,A7_D7
15 PIN_PA07,A8_D8
16 PIN_PA05,A9_D9
17 PIN_PA06,A10_D10
18 LED_PA17,USER_LED
19 LED_PA18,RX_LED
20 LED_PA19,TX_LED

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter van der Burg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Used by machine_pin.c & board specific pins.c. Holds Board/MCU specific Pin
* allocations.
*/
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_pin_obj_t;
typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
} machine_led_obj_t;
// MUST explicitly hold array # of rows, else machine_pin.c wont compile.
extern const machine_pin_obj_t machine_pin_obj[11];
extern const machine_led_obj_t machine_led_obj[3];

View File

@ -0,0 +1,126 @@
#!/usr/bin/env python
"""Generates the pins file for the SAMD port."""
from __future__ import print_function
import argparse
import sys
import csv
pins_header_prefix = """// This file was automatically generated by make-pins.py
//
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
uint32_t id;
char *name;
} machine_pin_obj_t;
"""
led_header_prefix = """typedef struct _machine_led_obj_t {
mp_obj_base_t base;
uint32_t id;
char *name;
} machine_led_obj_t;
"""
class Pins:
def __init__(self):
self.board_pins = [] # list of pin objects
self.board_leds = [] # list of led objects
def parse_csv_file(self, filename):
with open(filename, "r") as csvfile:
rows = csv.reader(csvfile)
for row in rows:
# Pin numbers must start with "PIN_"
# LED numbers must start with "LED_"
if len(row) > 0:
if row[0].strip().startswith("PIN_"):
if len(row) == 1:
self.board_pins.append([row[0], row[0][4:]])
else:
self.board_pins.append([row[0], row[1]])
elif row[0].strip().startswith("LED_"):
self.board_leds.append(["PIN_" + row[0][4:], row[1]])
elif row[0].strip().startswith("-"):
self.board_pins.append(["-1", ""])
def print_pins(self, pins_filename):
with open(pins_filename, "wt") as pins_file:
pins_file.write("// This file was automatically generated by make-pins.py\n")
pins_file.write("//\n")
pins_file.write('#include "modmachine.h"\n')
pins_file.write('#include "sam.h"\n')
pins_file.write('#include "pins.h"\n\n')
pins_file.write("const machine_pin_obj_t machine_pin_obj[] = {\n")
for pin in self.board_pins:
pins_file.write(" {{&machine_pin_type}, ")
pins_file.write(pin[0] + ', "' + pin[1])
pins_file.write('"},\n')
pins_file.write("};\n")
if self.board_leds:
pins_file.write("\nconst machine_led_obj_t machine_led_obj[] = {\n")
for pin in self.board_leds:
pins_file.write(" {{&machine_pin_type}, ")
pins_file.write(pin[0] + ', "' + pin[1])
pins_file.write('"},\n')
pins_file.write("};\n")
def print_header(self, hdr_filename):
with open(hdr_filename, "wt") as hdr_file:
hdr_file.write(pins_header_prefix)
if self.board_leds:
hdr_file.write(led_header_prefix)
hdr_file.write(
"extern const machine_pin_obj_t machine_pin_obj[%d];\n" % len(self.board_pins)
)
if self.board_leds:
hdr_file.write(
"extern const machine_led_obj_t machine_led_obj[%d];\n" % len(self.board_leds)
)
def main():
parser = argparse.ArgumentParser(
prog="make-pins.py",
usage="%(prog)s [options] [command]",
description="Generate board specific pin file",
)
parser.add_argument(
"-b",
"--board",
dest="csv_filename",
help="Specifies the pins.csv filename",
)
parser.add_argument(
"-p",
"--pins",
dest="pins_filename",
help="Specifies the name of the generated pins.c file",
)
parser.add_argument(
"-i",
"--inc",
dest="hdr_filename",
help="Specifies name of generated pin header file",
)
args = parser.parse_args(sys.argv[1:])
pins = Pins()
if args.csv_filename:
pins.parse_csv_file(args.csv_filename)
if args.pins_filename:
pins.print_pins(args.pins_filename)
pins.print_header(args.hdr_filename)
if __name__ == "__main__":
main()