Skip to content

Commit b3283d2

Browse files
authored
Merge pull request #9604 from jamesbowman/extended_opcodes
Extend EVE hardware opcodes for future-compatibility
2 parents 8efae20 + 16405df commit b3283d2

File tree

6 files changed

+78
-6
lines changed

6 files changed

+78
-6
lines changed

docs/shared_bindings_matrix.py

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

6666
ADDITIONAL_MODULES = {
6767
"_asyncio": "MICROPY_PY_ASYNCIO",
68+
"_eve": "CIRCUITPY__EVE",
6869
"adafruit_bus_device": "CIRCUITPY_BUSDEVICE",
6970
"adafruit_pixelbuf": "CIRCUITPY_PIXELBUF",
7071
"array": "CIRCUITPY_ARRAY",

ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
#define DEFAULT_UART_BUS_RX (&pin_PB17)
2929
#define DEFAULT_UART_BUS_TX (&pin_PB16)
3030

31+
// Used for 32 kHZ crystal
32+
#define IGNORE_PIN_PA00 1
33+
#define IGNORE_PIN_PA01 1
34+
3135
// USB is always used internally so skip the pin objects for it.
3236
#define IGNORE_PIN_PA24 1
3337
#define IGNORE_PIN_PA25 1
38+
39+
// Not connected
40+
#define IGNORE_PIN_PA15 1
41+
#define IGNORE_PIN_PA27 1
42+
#define IGNORE_PIN_PB00 1
43+
#define IGNORE_PIN_PB04 1
44+
#define IGNORE_PIN_PB06 1
45+
#define IGNORE_PIN_PB07 1
46+
#define IGNORE_PIN_PB30 1
47+
#define IGNORE_PIN_PB31 1

ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
#define DEFAULT_UART_BUS_RX (&pin_PA23)
3333
#define DEFAULT_UART_BUS_TX (&pin_PA22)
3434

35+
// Used for 32 kHz crystal
36+
#define IGNORE_PIN_PA00 1
37+
#define IGNORE_PIN_PA01 1
38+
3539
// USB is always used internally so skip the pin objects for it.
3640
#define IGNORE_PIN_PA24 1
3741
#define IGNORE_PIN_PA25 1
42+
43+
// Not connected
44+
#define IGNORE_PIN_PA07 1
45+
#define IGNORE_PIN_PA15 1
46+
#define IGNORE_PIN_PB00 1
47+
#define IGNORE_PIN_PB01 1
48+
#define IGNORE_PIN_PB04 1
49+
#define IGNORE_PIN_PB05 1
50+
#define IGNORE_PIN_PB23 1

shared-bindings/_eve/__init__.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize);
214214
//| def BitmapSource(self, addr: int) -> None:
215215
//| """Set the source address for bitmap graphics
216216
//|
217-
//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215
217+
//| :param int addr: Bitmap start address, pixel-aligned, low part.
218218
//| """
219219
//| ...
220220

@@ -225,6 +225,20 @@ static mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) {
225225
}
226226
static MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource);
227227

228+
//| def BitmapSourceH(self, addr: int) -> None:
229+
//| """Set the high source address for bitmap graphics
230+
//|
231+
//| :param int addr: Bitmap start address, pixel-aligned, high part.
232+
//| """
233+
//| ...
234+
235+
static mp_obj_t _bitmapsourceh(mp_obj_t self, mp_obj_t a0) {
236+
uint32_t addr = mp_obj_get_int_truncated(a0);
237+
common_hal__eve_BitmapSourceH(EVEHAL(self), addr);
238+
return mp_const_none;
239+
}
240+
static MP_DEFINE_CONST_FUN_OBJ_2(bitmapsourceh_obj, _bitmapsourceh);
241+
228242
//| def BitmapSwizzle(self, r: int, g: int, b: int, a: int) -> None:
229243
//| """Set the source for the r,g,b and a channels of a bitmap
230244
//|
@@ -650,7 +664,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop);
650664
//| def PaletteSource(self, addr: int) -> None:
651665
//| """Set the base address of the palette
652666
//|
653-
//| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0
667+
//| :param int addr: Address in graphics RAM, 2-byte aligned, low part.
654668
//|
655669
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
656670
//| """
@@ -663,6 +677,22 @@ static mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) {
663677
}
664678
static MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource);
665679

680+
//| def PaletteSourceH(self, addr: int) -> None:
681+
//| """Set the base address of the palette
682+
//|
683+
//| :param int addr: Address in graphics RAM, 2-byte aligned, high part.
684+
//|
685+
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
686+
//| """
687+
//| ...
688+
689+
static mp_obj_t _palettesourceh(mp_obj_t self, mp_obj_t a0) {
690+
uint32_t addr = mp_obj_get_int_truncated(a0);
691+
common_hal__eve_PaletteSourceH(EVEHAL(self), addr);
692+
return mp_const_none;
693+
}
694+
static MP_DEFINE_CONST_FUN_OBJ_2(palettesourceh_obj, _palettesourceh);
695+
666696
//| def RestoreContext(self) -> None:
667697
//| """Restore the current graphics context from the context stack"""
668698
//| ...
@@ -854,6 +884,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii);
854884
{ MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, \
855885
{ MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, \
856886
{ MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, \
887+
{ MP_ROM_QSTR(MP_QSTR_BitmapSourceH), MP_ROM_PTR(&bitmapsourceh_obj) }, \
857888
{ MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, \
858889
{ MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, \
859890
{ MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, \
@@ -879,6 +910,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii);
879910
{ MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(&macro_obj) }, \
880911
{ MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, \
881912
{ MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, \
913+
{ MP_ROM_QSTR(MP_QSTR_PaletteSourceH), MP_ROM_PTR(&palettesourceh_obj) }, \
882914
{ MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, \
883915
{ MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, \
884916
{ MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, \

shared-bindings/_eve/__init__.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint3
2121
void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height);
2222
void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height);
2323
void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr);
24+
void common_hal__eve_BitmapSourceH(common_hal__eve_t *eve, uint32_t addr);
2425
void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a);
2526
void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t p, uint32_t v);
2627
void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t p, uint32_t v);
@@ -46,6 +47,7 @@ void common_hal__eve_LineWidth(common_hal__eve_t *eve, mp_float_t width);
4647
void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m);
4748
void common_hal__eve_Nop(common_hal__eve_t *eve);
4849
void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr);
50+
void common_hal__eve_PaletteSourceH(common_hal__eve_t *eve, uint32_t addr);
4951
void common_hal__eve_PointSize(common_hal__eve_t *eve, mp_float_t size);
5052
void common_hal__eve_RestoreContext(common_hal__eve_t *eve);
5153
void common_hal__eve_Return(common_hal__eve_t *eve);

shared-module/_eve/__init__.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt) {
7575

7676

7777
void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle) {
78-
C4(eve, ((5 << 24) | ((handle & 31))));
78+
C4(eve, ((5 << 24) | ((handle & 63))));
7979
}
8080

8181

@@ -104,6 +104,11 @@ void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr) {
104104
}
105105

106106

107+
void common_hal__eve_BitmapSourceH(common_hal__eve_t *eve, uint32_t addr) {
108+
C4(eve, ((49 << 24) | ((addr & 0xff))));
109+
}
110+
111+
107112
void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) {
108113
C4(eve, ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7))));
109114
}
@@ -175,7 +180,7 @@ void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s) {
175180

176181

177182
void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s) {
178-
C4(eve, ((18 << 24) | ((s & 255))));
183+
C4(eve, ((18 << 24) | ((s & 0xffffff))));
179184
}
180185

181186

@@ -226,7 +231,12 @@ void common_hal__eve_Nop(common_hal__eve_t *eve) {
226231

227232

228233
void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) {
229-
C4(eve, ((42 << 24) | (((addr) & 4194303))));
234+
C4(eve, ((42 << 24) | (((addr) & 0xffffff))));
235+
}
236+
237+
238+
void common_hal__eve_PaletteSourceH(common_hal__eve_t *eve, uint32_t addr) {
239+
C4(eve, ((50 << 24) | (((addr) & 0xff))));
230240
}
231241

232242

@@ -282,7 +292,7 @@ void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask) {
282292

283293

284294
void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) {
285-
C4(eve, ((3 << 24) | ((s & 255))));
295+
C4(eve, ((3 << 24) | ((s & 0xffffff))));
286296
}
287297

288298

0 commit comments

Comments
 (0)