Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-ch32v003.h
Go to the documentation of this file.
1
6
7#ifndef _HDW_CH32V003_H_
8#define _HDW_CH32V003_H_
9
10#include <stdbool.h>
11#include <stdint.h>
12#include <driver/gpio.h>
13
14int initCh32v003(int swdio_pin);
15
16#define CH32V003_MAX_IMAGE_SLOTS 20
17
26#define ch32v003RunBinaryAsset(asset) \
27 ({ \
28 size_t sz; \
29 const uint8_t* buf = cnfsGetFile(asset, &sz); \
30 int r = ch32v003WriteFlash(buf, sz); \
31 ch32v003Resume(); \
32 r; \
33 })
34
35// More nitty gritty functions
36
37int ch32v003WriteFlash(const uint8_t* buf, int sz);
38int ch32v003WriteMemory(const uint8_t* binary, uint32_t length, uint32_t address);
39int ch32v003ReadMemory(uint8_t* binary, uint32_t length, uint32_t address);
40int ch32v003GetReg(int regno, uint32_t* value);
41int ch32v003SetReg(int regno, uint32_t regValue);
42int ch32v003Resume();
44void ch32v003Teardown();
45
46int ch32v003WriteBitmapAsset(int slot, int asset_idx);
47int ch32v003WriteBitmap(int slot, uint8_t pixels[6][12]);
48int ch32v003SelectBitmap(int slot);
49
50// Only available on the emulator
51void ch32v003EmuDraw(int window_w, int window_h);
52
53#endif
int ch32v003WriteBitmap(int slot, uint8_t pixels[6][12])
Write a 12x6 pixel greyscale image into a RAM slot on the ch32v003.
Definition hdw-ch32v003.c:422
int initCh32v003(int swdio_pin)
Definition hdw-ch32v003.c:102
int ch32v003WriteFlash(const uint8_t *buf, int sz)
Write data into the ch32v003's flash.
Definition hdw-ch32v003.c:206
void ch32v003Teardown()
Disables ch32v003 communications.
Definition hdw-ch32v003.c:365
int ch32v003WriteBitmapAsset(int slot, int asset_idx)
Halt the processor, and write to RAM a greyscale asset image.
Definition hdw-ch32v003.c:390
int ch32v003Resume()
Cause the 003 to reboot and execute the program loaded into it.
Definition hdw-ch32v003.c:264
int ch32v003GetReg(int regno, uint32_t *value)
Read ch32v003 debug module registers.
Definition hdw-ch32v003.c:320
int ch32v003WriteMemory(const uint8_t *binary, uint32_t length, uint32_t address)
Write to memory on the ch32v003.
Definition hdw-ch32v003.c:133
void ch32v003CheckTerminal()
See if the ch32v003 has any pending printf to print on host processor.
Definition hdw-ch32v003.c:349
int ch32v003ReadMemory(uint8_t *binary, uint32_t length, uint32_t address)
Read data from the ch32v003's memory space into host processor memory space.
Definition hdw-ch32v003.c:288
int ch32v003SelectBitmap(int slot)
Override the DMA pointer on the 003 to point at a pre-loaded image in RAM.
Definition hdw-ch32v003.c:472
int ch32v003SetReg(int regno, uint32_t regValue)
Write ch32v003 debug module registers.
Definition hdw-ch32v003.c:335
void ch32v003EmuDraw(int window_w, int window_h)