nrf: fixups for changes from 2.2
1. bidirectional SPI support (@microbuilder please check) 2. slight changes in DigitalIO types 3. placeholders (not implemented yet) for single/double-click bootloader support
This commit is contained in:
parent
d8686cc002
commit
19d353ccd9
|
@ -137,25 +137,25 @@ SRC_C += \
|
|||
help.c \
|
||||
pin_named_pins.c \
|
||||
fatfs_port.c \
|
||||
fifo.c \
|
||||
fifo.c \
|
||||
drivers/softpwm.c \
|
||||
drivers/ticker.c \
|
||||
drivers/bluetooth/ble_drv.c \
|
||||
drivers/bluetooth/ble_uart.c \
|
||||
boards/$(BOARD)/board.c \
|
||||
boards/$(BOARD)/pins.c \
|
||||
boards/$(BOARD)/board.c \
|
||||
boards/$(BOARD)/pins.c \
|
||||
device/$(MCU_VARIANT)/system_$(MCU_SUB_VARIANT).c \
|
||||
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
|
||||
lib/oofatfs/ff.c \
|
||||
lib/oofatfs/option/ccsbcs.c \
|
||||
lib/timeutils/timeutils.c \
|
||||
lib/utils/buffer_helper.c \
|
||||
lib/utils/context_manager_helpers.c \
|
||||
lib/utils/interrupt_char.c \
|
||||
lib/utils/pyexec.c \
|
||||
lib/timeutils/timeutils.c \
|
||||
lib/utils/buffer_helper.c \
|
||||
lib/utils/context_manager_helpers.c \
|
||||
lib/utils/interrupt_char.c \
|
||||
lib/utils/pyexec.c \
|
||||
lib/libc/string0.c \
|
||||
lib/mp-readline/readline.c \
|
||||
internal_flash.c \
|
||||
internal_flash.c \
|
||||
|
||||
|
||||
DRIVERS_SRC_C += $(addprefix modules/,\
|
||||
|
@ -196,18 +196,18 @@ SRC_COMMON_HAL += \
|
|||
microcontroller/Pin.c \
|
||||
microcontroller/Processor.c \
|
||||
os/__init__.c \
|
||||
time/__init__.c \
|
||||
time/__init__.c \
|
||||
analogio/__init__.c \
|
||||
analogio/AnalogIn.c \
|
||||
analogio/AnalogOut.c \
|
||||
busio/__init__.c\
|
||||
busio/I2C.c \
|
||||
busio/SPI.c \
|
||||
pulseio/__init__.c \
|
||||
pulseio/__init__.c \
|
||||
pulseio/PulseIn.c \
|
||||
pulseio/PulseOut.c \
|
||||
pulseio/PWMOut.c \
|
||||
storage/__init__.c \
|
||||
pulseio/PWMOut.c \
|
||||
storage/__init__.c \
|
||||
|
||||
# These don't have corresponding files in each port but are still located in
|
||||
# shared-bindings to make it clear what the contents of the modules are.
|
||||
|
@ -215,6 +215,7 @@ SRC_BINDINGS_ENUMS = \
|
|||
digitalio/Direction.c \
|
||||
digitalio/DriveMode.c \
|
||||
digitalio/Pull.c \
|
||||
microcontroller/RunMode.c \
|
||||
help.c \
|
||||
math/__init__.c \
|
||||
supervisor/__init__.c \
|
||||
|
@ -225,7 +226,7 @@ SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
|||
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
||||
|
||||
SRC_SHARED_MODULE = \
|
||||
os/__init__.c \
|
||||
os/__init__.c \
|
||||
random/__init__.c \
|
||||
storage/__init__.c \
|
||||
|
||||
|
|
|
@ -160,3 +160,27 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len,
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
|
||||
if (len == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
while (len)
|
||||
{
|
||||
self->spi->TXD = *data_out;
|
||||
|
||||
while(!self->spi->EVENTS_READY);
|
||||
|
||||
*data_in = self->spi->RXD;
|
||||
|
||||
data_out++;
|
||||
data_in++;
|
||||
len--;
|
||||
|
||||
self->spi->EVENTS_READY = 0x0UL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self
|
|||
}
|
||||
|
||||
void common_hal_digitalio_digitalinout_switch_to_input(
|
||||
digitalio_digitalinout_obj_t* self, enum digitalio_pull_t pull) {
|
||||
digitalio_digitalinout_obj_t* self, digitalio_pull_t pull) {
|
||||
self->output = false;
|
||||
|
||||
hal_gpio_cfg_pin(self->pin->port, self->pin->pin, HAL_GPIO_MODE_INPUT, HAL_GPIO_PULL_DISABLED);
|
||||
|
@ -64,7 +64,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
|
|||
|
||||
void common_hal_digitalio_digitalinout_switch_to_output(
|
||||
digitalio_digitalinout_obj_t* self, bool value,
|
||||
enum digitalio_drive_mode_t drive_mode) {
|
||||
digitalio_drive_mode_t drive_mode) {
|
||||
const uint8_t pin = self->pin->pin;
|
||||
|
||||
self->output = true;
|
||||
|
@ -74,7 +74,7 @@ void common_hal_digitalio_digitalinout_switch_to_output(
|
|||
common_hal_digitalio_digitalinout_set_value(self, value);
|
||||
}
|
||||
|
||||
enum digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
|
||||
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
|
||||
digitalio_digitalinout_obj_t* self) {
|
||||
return self->output? DIRECTION_OUTPUT : DIRECTION_INPUT;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ bool common_hal_digitalio_digitalinout_get_value(
|
|||
|
||||
void common_hal_digitalio_digitalinout_set_drive_mode(
|
||||
digitalio_digitalinout_obj_t* self,
|
||||
enum digitalio_drive_mode_t drive_mode) {
|
||||
digitalio_drive_mode_t drive_mode) {
|
||||
bool value = common_hal_digitalio_digitalinout_get_value(self);
|
||||
self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN;
|
||||
// True is implemented differently between modes so reset the value to make
|
||||
|
@ -120,7 +120,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
|
|||
}
|
||||
}
|
||||
|
||||
enum digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
|
||||
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
|
||||
digitalio_digitalinout_obj_t* self) {
|
||||
if (self->open_drain) {
|
||||
return DRIVE_MODE_OPEN_DRAIN;
|
||||
|
@ -130,7 +130,7 @@ enum digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
|
|||
}
|
||||
|
||||
void common_hal_digitalio_digitalinout_set_pull(
|
||||
digitalio_digitalinout_obj_t* self, enum digitalio_pull_t pull) {
|
||||
digitalio_digitalinout_obj_t* self, digitalio_pull_t pull) {
|
||||
hal_gpio_pull_t asf_pull = HAL_GPIO_PULL_DISABLED;
|
||||
switch (pull) {
|
||||
case PULL_UP:
|
||||
|
@ -146,7 +146,7 @@ void common_hal_digitalio_digitalinout_set_pull(
|
|||
hal_gpio_pull_set(self->pin->port, self->pin->pin, asf_pull);
|
||||
}
|
||||
|
||||
enum digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
|
||||
digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
|
||||
digitalio_digitalinout_obj_t* self) {
|
||||
uint32_t pin = self->pin->pin;
|
||||
if (self->output) {
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
|
||||
|
@ -41,9 +43,17 @@ void common_hal_mcu_disable_interrupts() {
|
|||
void common_hal_mcu_enable_interrupts() {
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, returned by microcontroller.cpu
|
||||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||
// TODO: see atmel-samd for functionality
|
||||
}
|
||||
|
||||
void common_hal_mcu_reset(void) {
|
||||
// TODO: see atmel-samd for functionality
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
.base = {
|
||||
.type = &mcu_processor_type,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue