|
Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
This file contains the header to control the semihosted ch32v003 via the swio programming pin.
Go to the source code of this file.
Macros | |
| #define | EYE_LED_OFF 0x00 |
| #define | EYE_LED_DIM 0x08 |
| #define | EYE_LED_BRIGHT 0x10 |
| #define | EYE_LED_W 12 |
| #define | EYE_LED_H 6 |
| #define | CH32V003_MAX_IMAGE_SLOTS 20 |
| #define | ch32v003RunBinaryAsset(asset) |
Load and run a binary image from the assets folder on the ch32v003. Included as a #define because we can't include main functionality in a module. | |
Functions | |
| int | initCh32v003 (int swdio_pin) |
| int | ch32v003WriteFlash (const uint8_t *buf, int sz) |
| Write data into the ch32v003's flash. | |
| int | ch32v003WriteMemory (const uint8_t *binary, uint32_t length, uint32_t address) |
| Write to memory on the ch32v003. | |
| int | ch32v003ReadMemory (uint8_t *binary, uint32_t length, uint32_t address) |
| Read data from the ch32v003's memory space into host processor memory space. | |
| int | ch32v003GetReg (int regno, uint32_t *value) |
| Read ch32v003 debug module registers. | |
| int | ch32v003SetReg (int regno, uint32_t regValue) |
| Write ch32v003 debug module registers. | |
| int | ch32v003Resume () |
| Cause the 003 to reboot and execute the program loaded into it. | |
| void | ch32v003CheckTerminal () |
| See if the ch32v003 has any pending printf to print on host processor. | |
| void | ch32v003Teardown () |
| Disables ch32v003 communications. | |
| int | ch32v003WriteBitmapAsset (int slot, int asset_idx) |
| Halt the processor, and write to RAM a greyscale asset image. | |
| int | ch32v003WriteBitmap (int slot, const uint8_t pixels[6][12]) |
| int | ch32v003SelectBitmap (int slot) |
| Override the DMA pointer on the 003 to point at a pre-loaded image in RAM. | |
| #define EYE_LED_OFF 0x00 |
| #define EYE_LED_DIM 0x08 |
| #define EYE_LED_BRIGHT 0x10 |
| #define EYE_LED_W 12 |
| #define EYE_LED_H 6 |
| #define CH32V003_MAX_IMAGE_SLOTS 20 |
| #define ch32v003RunBinaryAsset | ( | asset | ) |
Load and run a binary image from the assets folder on the ch32v003. Included as a #define because we can't include main functionality in a module.
| asset | cnfsFileIdx_t of a binary image to be loaded into a location in the ch32v003. This must be of type cnfsFileIdx_t |
| int initCh32v003 | ( | int | swdio_pin | ) |
| int ch32v003WriteFlash | ( | const uint8_t * | buf, |
| int | sz ) |
Write data into the ch32v003's flash.
| buf | A pointer to a binary image in the master processor |
| sz | The size of the binary image to be written |
| int ch32v003WriteMemory | ( | const uint8_t * | binary, |
| uint32_t | length, | ||
| uint32_t | offset ) |
Write to memory on the ch32v003.
| binary | A binary image to be loaded into a location in the ch32v003. |
| length | The size of the binary image. |
| offset | The offset of the binary image.s |
| int ch32v003ReadMemory | ( | uint8_t * | binary, |
| uint32_t | length, | ||
| uint32_t | offset ) |
Read data from the ch32v003's memory space into host processor memory space.
| binary | A pointer to a buffer in the host processor |
| length | The number of bytes to read |
| offset | The location of memory to read in the ch32v003 |
| int ch32v003GetReg | ( | int | regno, |
| uint32_t * | value ) |
Read ch32v003 debug module registers.
| regno | The debug module register number. |
| value | A pointer to the uint32_t to receive that register's value. |
| int ch32v003SetReg | ( | int | regno, |
| uint32_t | regValue ) |
Write ch32v003 debug module registers.
| regno | The debug module register number. |
| regValue | The value to write into that debug module regsiter |
| int ch32v003Resume | ( | ) |
Cause the 003 to reboot and execute the program loaded into it.
| void ch32v003CheckTerminal | ( | ) |
See if the ch32v003 has any pending printf to print on host processor.
| void ch32v003Teardown | ( | ) |
Disables ch32v003 communications.
| int ch32v003WriteBitmapAsset | ( | int | slot, |
| int | asset_idx ) |
Halt the processor, and write to RAM a greyscale asset image.
| slot | Must be less than CH32V003_MAX_IMAGE_SLOTS. |
| asset_idx | Is a .gs.png asset, for instance EYES_DEFAULT_GS (From eyes_default.gs.png). This image must be EYE_LED_W x EYE_LED_H pixels in size. |
| int ch32v003WriteBitmap | ( | int | slot, |
| const uint8_t | pixels[6][12] ) |
| int ch32v003SelectBitmap | ( | int | slot | ) |
Override the DMA pointer on the 003 to point at a pre-loaded image in RAM.
| slot | Must be less than CH32V003_MAX_IMAGE_SLOTS. |