atsam: Use enumerations for buses and reserve pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7765653d83
commit
7e8ecfe177
|
@ -94,7 +94,7 @@ position_max: 250
|
|||
|
||||
[tmc2660 stepper_x]
|
||||
cs_pin: PD14 # X_SPI_EN Required for communication
|
||||
spi_bus: 1 # All TMC2660 drivers are connected to USART1, which is bus 1 on the sam4e port
|
||||
spi_bus: usart1 # All TMC2660 drivers are connected to USART1
|
||||
microsteps: 16
|
||||
interpolate: True # 1/16 micro-steps interpolated to 1/256
|
||||
run_current: 1.000
|
||||
|
@ -112,7 +112,7 @@ position_max: 210
|
|||
|
||||
[tmc2660 stepper_y]
|
||||
cs_pin: PC9
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -130,7 +130,7 @@ position_max: 200
|
|||
|
||||
[tmc2660 stepper_z]
|
||||
cs_pin: PC10
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -145,7 +145,7 @@ step_distance: .0025
|
|||
|
||||
[tmc2660 stepper_z1]
|
||||
cs_pin: PD25
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -160,7 +160,7 @@ step_distance: .0025
|
|||
|
||||
[tmc2660 stepper_z2]
|
||||
cs_pin: PD26
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -175,7 +175,7 @@ step_distance: .0025
|
|||
|
||||
[tmc2660 stepper_z3]
|
||||
cs_pin: PC28
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -201,7 +201,7 @@ max_temp: 250
|
|||
|
||||
[tmc2660 extruder0]
|
||||
cs_pin: PC17
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -227,7 +227,7 @@ max_temp: 250
|
|||
|
||||
[tmc2660 extruder1]
|
||||
cs_pin: PC25
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -253,7 +253,7 @@ max_temp: 250
|
|||
|
||||
[tmc2660 extruder2]
|
||||
cs_pin: PD23
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
@ -279,7 +279,7 @@ max_temp: 250
|
|||
|
||||
[tmc2660 extruder3]
|
||||
cs_pin: PD24
|
||||
spi_bus: 1
|
||||
spi_bus: usart1
|
||||
microsteps: 16
|
||||
interpolate: True
|
||||
run_current: 1.000
|
||||
|
|
|
@ -12,16 +12,21 @@
|
|||
#include "sched.h" // sched_shutdown
|
||||
|
||||
// I2C pin definitions
|
||||
DECL_ENUMERATION_RANGE("i2c_bus", "twi0", 0, 2);
|
||||
#if CONFIG_MACH_SAM3X
|
||||
#define TWI0_SCL_GPIO GPIO('A', 18)
|
||||
#define TWI0_SDA_GPIO GPIO('A', 17)
|
||||
#define TWI1_SCL_GPIO GPIO('B', 13)
|
||||
#define TWI1_SDA_GPIO GPIO('B', 12)
|
||||
DECL_CONSTANT_STR("BUS_PINS_twi0", "PA18,PA17");
|
||||
DECL_CONSTANT_STR("BUS_PINS_twi1", "PB13,PB12");
|
||||
#elif CONFIG_MACH_SAM4
|
||||
#define TWI0_SCL_GPIO GPIO('A', 4)
|
||||
#define TWI0_SDA_GPIO GPIO('A', 3)
|
||||
#define TWI1_SCL_GPIO GPIO('B', 5)
|
||||
#define TWI1_SDA_GPIO GPIO('B', 4)
|
||||
DECL_CONSTANT_STR("BUS_PINS_twi0", "PA4,PA3");
|
||||
DECL_CONSTANT_STR("BUS_PINS_twi1", "PB5,PB4");
|
||||
#endif
|
||||
|
||||
static void
|
||||
|
@ -89,7 +94,7 @@ addr_to_u32(uint8_t addr_len, uint8_t *addr)
|
|||
struct i2c_config
|
||||
i2c_setup(uint32_t bus, uint32_t rate, uint8_t addr)
|
||||
{
|
||||
if ((bus > 1) | (rate > 400000))
|
||||
if (bus > 1 || rate > 400000)
|
||||
shutdown("Invalid i2c_setup parameters!");
|
||||
Twi *p_twi = (bus == 0) ? TWI0 : TWI1;
|
||||
i2c_init(p_twi, rate);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "board/irq.h" // irq_disable
|
||||
#include "board/usb_cdc.h" // usb_notify_ep0
|
||||
#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN
|
||||
#include "command.h" // DECL_CONSTANT_STR
|
||||
#include "internal.h" // UDP
|
||||
#include "sched.h" // DECL_INIT
|
||||
|
||||
|
@ -159,6 +160,8 @@ usb_set_configure(void)
|
|||
UDP->UDP_GLB_STAT |= UDP_GLB_STAT_CONFG;
|
||||
}
|
||||
|
||||
DECL_CONSTANT_STR("RESERVE_PINS_USB", "PB10,PB11");
|
||||
|
||||
void
|
||||
usbserial_init(void)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "autoconf.h" // CONFIG_SERIAL_BAUD
|
||||
#include "board/serial_irq.h" // serial_rx_data
|
||||
#include "command.h" // DECL_CONSTANT_STR
|
||||
#include "internal.h" // gpio_peripheral
|
||||
#include "sched.h" // DECL_INIT
|
||||
|
||||
|
@ -16,18 +17,21 @@ static Uart * const Port = UART;
|
|||
static const uint32_t Pmc_id = ID_UART, Irq_id = UART_IRQn;
|
||||
static const uint32_t rx_pin = GPIO('A', 8);
|
||||
static const uint32_t tx_pin = GPIO('A', 9);
|
||||
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA8,PA9");
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
#define Serial_IRQ_Handler UART1_Handler
|
||||
static Uart * const Port = UART1;
|
||||
static const uint32_t Pmc_id = ID_UART1, Irq_id = UART1_IRQn;
|
||||
static const uint32_t rx_pin = GPIO('B', 2);
|
||||
static const uint32_t tx_pin = GPIO('B', 3);
|
||||
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB2,PB3");
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
#define Serial_IRQ_Handler UART0_Handler
|
||||
static Uart * const Port = UART0;
|
||||
static const uint32_t Pmc_id = ID_UART0, Irq_id = UART0_IRQn;
|
||||
static const uint32_t rx_pin = GPIO('A', 9);
|
||||
static const uint32_t tx_pin = GPIO('A', 10);
|
||||
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA9,PA10");
|
||||
#endif
|
||||
|
||||
void
|
||||
|
|
|
@ -22,6 +22,27 @@ struct spi_info {
|
|||
uint8_t miso_pin, mosi_pin, sck_pin, rxtx_periph, sck_periph;
|
||||
};
|
||||
|
||||
#if CONFIG_MACH_SAM3X
|
||||
DECL_ENUMERATION("spi_bus", "spi0", 0);
|
||||
DECL_ENUMERATION_RANGE("spi_bus", "usart0", 1, 3);
|
||||
DECL_CONSTANT_STR("BUS_PINS_spi0", "PA25,PA26,PA27");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart0", "PA10,PA11,PA17");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart1", "PA12,PA13,PA16");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart2", "PB21,PB20,PB24");
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
DECL_ENUMERATION("spi_bus", "spi", 0);
|
||||
DECL_ENUMERATION_RANGE("spi_bus", "usart0", 1, 2);
|
||||
DECL_CONSTANT_STR("BUS_PINS_spi", "PA12,PA13,PA14");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart0", "PA5,PA6,PA2");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart1", "PA21,PA22,PA23");
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
DECL_ENUMERATION("spi_bus", "spi", 0);
|
||||
DECL_ENUMERATION_RANGE("spi_bus", "usart0", 1, 2);
|
||||
DECL_CONSTANT_STR("BUS_PINS_spi", "PA12,PA13,PA14");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart0", "PB0,PB1,PB13");
|
||||
DECL_CONSTANT_STR("BUS_PINS_usart1", "PA21,PA22,PA23");
|
||||
#endif
|
||||
|
||||
static const struct spi_info spi_bus[] = {
|
||||
#if CONFIG_MACH_SAM3X
|
||||
{ SPI0, ID_SPI0, GPIO('A', 25), GPIO('A', 26), GPIO('A', 27), 'A', 'A' },
|
||||
|
@ -33,9 +54,9 @@ static const struct spi_info spi_bus[] = {
|
|||
{ USART0, ID_USART0, GPIO('A', 5), GPIO('A', 6), GPIO('A', 2), 'A', 'B' },
|
||||
{ USART1, ID_USART1, GPIO('A', 21), GPIO('A', 22), GPIO('A', 23), 'A', 'A'},
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
{ SPI, ID_SPI, GPIO('A', 12), GPIO('A', 13), GPIO('A', 14), 'A', 'A' },
|
||||
{ USART0, ID_USART0, GPIO('B', 0), GPIO('B', 1), GPIO('B', 13), 'C', 'C' },
|
||||
{ USART1, ID_USART1, GPIO('A', 21), GPIO('A', 22), GPIO('A', 23), 'A', 'A'},
|
||||
{ SPI, ID_SPI, GPIO('A', 12), GPIO('A', 13), GPIO('A', 14), 'A', 'A' },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue