Skip to content

Commit 884b2ea

Browse files
committed
In progress work to save space on the Gemma.
1 parent 92b48f4 commit 884b2ea

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

atmel-samd/boards/gemma_m0/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#define MICROPY_HW_APA102_MOSI &pin_PA04
77
#define MICROPY_HW_APA102_SCK &pin_PA05
8+
#define MICROPY_HW_APA102_SERCOM SERCOM0
89

910
#define MICROPY_PORT_A (PORT_PA04 | PORT_PA05 | PORT_PA24 | PORT_PA25)
1011
#define MICROPY_PORT_B (0)

atmel-samd/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,12 @@ void samd21_init(void) {
480480
tick_init();
481481

482482
// Uncomment to init PIN_PA17 for debugging.
483-
// struct port_config pin_conf;
484-
// port_get_config_defaults(&pin_conf);
485-
//
486-
// pin_conf.direction = PORT_PIN_DIR_OUTPUT;
487-
// port_pin_set_config(MICROPY_HW_LED1, &pin_conf);
488-
// port_pin_set_output_level(MICROPY_HW_LED1, false);
483+
struct port_config pin_conf;
484+
port_get_config_defaults(&pin_conf);
485+
486+
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
487+
port_pin_set_config(PIN_PA17, &pin_conf);
488+
port_pin_set_output_level(PIN_PA17, false);
489489

490490
rgb_led_status_init();
491491

atmel-samd/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ typedef long mp_off_t;
122122

123123
// extra built in modules to add to the list of known ones
124124
extern const struct _mp_obj_module_t microcontroller_module;
125-
extern const struct _mp_obj_module_t bitbangio_module;
126125
extern const struct _mp_obj_module_t nativeio_module;
127126
extern const struct _mp_obj_module_t board_module;
128127
extern const struct _mp_obj_module_t uos_module;
@@ -133,6 +132,7 @@ extern const struct _mp_obj_module_t samd_module;
133132

134133
// Internal flash size dependent settings.
135134
#if BOARD_FLASH_SIZE > 192000
135+
extern const struct _mp_obj_module_t bitbangio_module;
136136
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
137137
#define EXTRA_BUILTIN_MODULES \
138138
{ MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }

atmel-samd/rgb_led_status.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
#include "mphalport.h"
55

6-
#include "shared-bindings/bitbangio/SPI.h"
6+
#include "shared-bindings/nativeio/SPI.h"
77
#include "shared-bindings/nativeio/DigitalInOut.h"
88
#include "shared-bindings/neopixel_write/__init__.h"
9-
#include "shared-module/bitbangio/types.h"
9+
#include "common-hal/nativeio/types.h"
1010
#include "rgb_led_status.h"
1111
#include "samd21_pins.h"
1212

@@ -16,8 +16,8 @@ static nativeio_digitalinout_obj_t status_neopixel;
1616
#endif
1717

1818
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
19-
static uint8_t status_apa102_color[12] = {0, 0, 0, 0, 0xff, 0, 0, 0};
20-
static bitbangio_spi_obj_t status_apa102;
19+
static uint8_t status_apa102_color[12] = {0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0};
20+
static nativeio_spi_obj_t status_apa102;
2121
#endif
2222

2323
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
@@ -30,12 +30,14 @@ void rgb_led_status_init() {
3030
common_hal_nativeio_digitalinout_switch_to_output(&status_neopixel, false, DRIVE_MODE_PUSH_PULL);
3131
#endif
3232
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
33-
shared_module_bitbangio_spi_construct(&status_apa102,
34-
MICROPY_HW_APA102_SCK,
35-
MICROPY_HW_APA102_MOSI,
36-
NULL);
37-
shared_module_bitbangio_spi_try_lock(&status_apa102);
38-
shared_module_bitbangio_spi_configure(&status_apa102, 100000, 0, 1, 8);
33+
34+
port_pin_set_output_level(PIN_PA17, true);
35+
common_hal_nativeio_spi_construct(&status_apa102,
36+
MICROPY_HW_APA102_SCK,
37+
MICROPY_HW_APA102_MOSI,
38+
NULL);
39+
//common_hal_nativeio_spi_try_lock(&status_apa102);
40+
//common_hal_nativeio_spi_configure(&status_apa102, 100000, 0, 1, 8);
3941
#endif
4042
}
4143

@@ -57,7 +59,7 @@ void new_status_color(uint32_t rgb) {
5759
status_apa102_color[5] = rgb & 0xff;
5860
status_apa102_color[6] = (rgb >> 8) & 0xff;
5961
status_apa102_color[7] = (rgb >> 16) & 0xff;
60-
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 8);
62+
//common_hal_nativeio_spi_write(&status_apa102, status_apa102_color, 8);
6163
#endif
6264
}
6365

@@ -67,8 +69,8 @@ void temp_status_color(uint32_t rgb) {
6769
common_hal_neopixel_write(&status_neopixel, colors, 3, true);
6870
#endif
6971
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
70-
uint8_t colors[12] = {0, 0, 0, 0, 0xff, rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff, 0x0, 0x0, 0x0, 0x0};
71-
shared_module_bitbangio_spi_write(&status_apa102, colors, 8);
72+
//uint8_t colors[12] = {0, 0, 0, 0, 0xff, rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff, 0x0, 0x0, 0x0, 0x0};
73+
//common_hal_nativeio_spi_write(&status_apa102, colors, 8);
7274
#endif
7375
}
7476

@@ -77,7 +79,7 @@ void clear_temp_status() {
7779
common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3, true);
7880
#endif
7981
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
80-
shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 12);
82+
//common_hal_nativeio_spi_write(&status_apa102, status_apa102_color, 12);
8183
#endif
8284
}
8385

0 commit comments

Comments
 (0)