samd_sercom: Specify the sercom explicitly in a config option
Do not infer the sercom from the config section name, as that prevents one from using SPI buses on multiple samd mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
df43c9e9bf
commit
d1bdde56cc
|
@ -6,6 +6,9 @@ All dates in this document are approximate.
|
|||
|
||||
# Changes
|
||||
|
||||
20210703: A `samd_sercom` config section must now specify the sercom
|
||||
bus it is configuring via the `sercom` option.
|
||||
|
||||
20210612: The `pid_integral_max` config option in heater and
|
||||
temperature_fan sections is deprecated. The option will be removed in
|
||||
the near future.
|
||||
|
|
|
@ -3793,13 +3793,17 @@ i2c_address:
|
|||
## [samd_sercom]
|
||||
|
||||
SAMD SERCOM configuration to specify which pins to use on a given
|
||||
SERCOM. One may define one section with the "samd_sercom" prefix per
|
||||
SERCOM available. Each SERCOM must be configured prior to using it as
|
||||
SPI or I2C peripheral. Place this config section above any other
|
||||
section that makes use of SPI or I2C buses.
|
||||
SERCOM. One may define any number of sections with a "samd_sercom"
|
||||
prefix. Each SERCOM must be configured prior to using it as SPI or I2C
|
||||
peripheral. Place this config section above any other section that
|
||||
makes use of SPI or I2C buses.
|
||||
|
||||
```
|
||||
[samd_sercom sercom0]
|
||||
[samd_sercom my_sercom]
|
||||
sercom:
|
||||
# The name of the sercom bus to configure in the micro-controller.
|
||||
# Available names are "sercom0", "sercom1", etc.. This parameter
|
||||
# must be provided.
|
||||
tx_pin:
|
||||
# MOSI pin for SPI communication, or SDA (data) pin for I2C
|
||||
# communication. The pin must have a valid pinmux configuration
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
class SamdSERCOM:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
self.name = config.get_name().split()[1]
|
||||
|
||||
self.sercom = config.get("sercom")
|
||||
self.tx_pin = config.get("tx_pin")
|
||||
self.rx_pin = config.get("rx_pin", None)
|
||||
self.clk_pin = config.get("clk_pin")
|
||||
|
@ -18,7 +18,7 @@ class SamdSERCOM:
|
|||
self.mcu = tx_pin_params['chip']
|
||||
self.mcu.add_config_cmd(
|
||||
"set_sercom_pin bus=%s sercom_pin_type=tx pin=%s" % (
|
||||
self.name, tx_pin_params['pin']))
|
||||
self.sercom, tx_pin_params['pin']))
|
||||
|
||||
clk_pin_params = ppins.lookup_pin(self.clk_pin)
|
||||
if self.mcu is not clk_pin_params['chip']:
|
||||
|
@ -26,7 +26,7 @@ class SamdSERCOM:
|
|||
config.get_name(),))
|
||||
self.mcu.add_config_cmd(
|
||||
"set_sercom_pin bus=%s sercom_pin_type=clk pin=%s" % (
|
||||
self.name, clk_pin_params['pin']))
|
||||
self.sercom, clk_pin_params['pin']))
|
||||
|
||||
if self.rx_pin:
|
||||
rx_pin_params = ppins.lookup_pin(self.rx_pin)
|
||||
|
@ -35,7 +35,7 @@ class SamdSERCOM:
|
|||
config.get_name(),))
|
||||
self.mcu.add_config_cmd(
|
||||
"set_sercom_pin bus=%s sercom_pin_type=rx pin=%s" % (
|
||||
self.name, rx_pin_params['pin']))
|
||||
self.sercom, rx_pin_params['pin']))
|
||||
|
||||
def load_config_prefix(config):
|
||||
return SamdSERCOM(config)
|
||||
|
|
Loading…
Reference in New Issue