atmel-samd: Update and enable neopixel_write for ASF4, tested on SAMD21 only.
This commit is contained in:
parent
8c7571a75d
commit
d023879bea
@ -251,6 +251,7 @@ SRC_COMMON_HAL = \
|
||||
microcontroller/__init__.c \
|
||||
microcontroller/Pin.c \
|
||||
microcontroller/Processor.c \
|
||||
neopixel_write/__init__.c \
|
||||
os/__init__.c \
|
||||
time/__init__.c
|
||||
# analogio/__init__.c \
|
||||
|
@ -61,6 +61,6 @@ void reset_board(void) {
|
||||
common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23);
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
|
||||
DRIVE_MODE_PUSH_PULL);
|
||||
// common_hal_neopixel_write(&neopixel_pin, empty, 30);
|
||||
common_hal_neopixel_write(&neopixel_pin, empty, 30);
|
||||
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
|
||||
}
|
||||
|
@ -23,13 +23,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "hpl_gpio.h"
|
||||
|
||||
#include "mphalport.h"
|
||||
#include "py/mphal.h"
|
||||
|
||||
#include "shared-bindings/neopixel_write/__init__.h"
|
||||
|
||||
#include "asf/common2/services/delay/delay.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
|
||||
// This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code:
|
||||
@ -45,7 +44,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
|
||||
NVMCTRL->CTRLB.bit.READMODE = NVMCTRL_CTRLB_READMODE_DETERMINISTIC_Val;
|
||||
|
||||
uint32_t pin = digitalinout->pin->pin;
|
||||
port = port_get_group_from_gpio_pin(pin);
|
||||
port = &PORT->Group[GPIO_PORT(pin)]; // Convert GPIO # to port register
|
||||
pinMask = (1UL << (pin % 32)); // From port_pin_set_output_level ASF code.
|
||||
ptr = pixels;
|
||||
end = ptr + numBytes;
|
||||
@ -83,5 +82,5 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
|
||||
// 50us delay to let pixels latch to the data that was just sent.
|
||||
// This could be optimized to only occur before pixel writes when necessary,
|
||||
// like in the Arduino library.
|
||||
delay_us(50);
|
||||
mp_hal_delay_us(50);
|
||||
}
|
||||
|
@ -215,7 +215,6 @@ extern const struct _mp_obj_module_t usb_hid_module;
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module },
|
||||
// { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module },
|
||||
@ -225,6 +224,7 @@ extern const struct _mp_obj_module_t usb_hid_module;
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \
|
||||
|
Loading…
Reference in New Issue
Block a user