Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-ch32v003.c File Reference

Macros

#define MAX_IN_TIMEOUT   1000
 
#define DisableISR()
 
#define EnableISR()
 
#define GPIO_VAR_W1TC   (*GPIO_VAR_W1TC_R)
 
#define GPIO_VAR_W1TS   (*GPIO_VAR_W1TS_R)
 
#define GPIO_VAR_ENABLE_W1TC   (*GPIO_VAR_ENABLE_W1TC_R)
 
#define GPIO_VAR_ENABLE_W1TS   (*GPIO_VAR_ENABLE_W1TS_R)
 
#define GPIO_VAR_IN   (*GPIO_VAR_IN_R)
 
#define IO_MUX_REG(x)
 
#define XIO_MUX_REG(x)
 
#define GPIO_NUM(x)
 
#define XGPIO_NUM(x)
 

Functions

int uprintf (const char *fmt,...)
 vaprintf stand-in for USB logging.
 
int initCh32v003 (int swdio_pin)
 
int ch32v003WriteMemory (const uint8_t *binary, uint32_t length, uint32_t offset)
 Write to memory on the ch32v003.
 
int ch32v003WriteFlash (const uint8_t *buf, int sz)
 Write data into the ch32v003's flash.
 
int ch32v003Resume ()
 Cause the 003 to reboot and execute the program loaded into it.
 
int ch32v003ReadMemory (uint8_t *binary, uint32_t length, uint32_t offset)
 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.
 
void ch32v003CheckTerminal ()
 See if the ch32v003 has any pending printf to print on host processor.
 
void ch32v003Teardown ()
 Disables ch32v003 communications.
 

Variables

struct SWIOState swioContext
 

Macro Definition Documentation

◆ MAX_IN_TIMEOUT

#define MAX_IN_TIMEOUT   1000

◆ DisableISR

#define DisableISR ( )
Value:
do \
{ \
XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); \
portbenchmarkINTERRUPT_DISABLE(); \
} while (0)

◆ EnableISR

#define EnableISR ( )
Value:
do \
{ \
portbenchmarkINTERRUPT_RESTORE(0); \
XTOS_SET_INTLEVEL(0); \
} while (0)

◆ GPIO_VAR_W1TC

#define GPIO_VAR_W1TC   (*GPIO_VAR_W1TC_R)

◆ GPIO_VAR_W1TS

#define GPIO_VAR_W1TS   (*GPIO_VAR_W1TS_R)

◆ GPIO_VAR_ENABLE_W1TC

#define GPIO_VAR_ENABLE_W1TC   (*GPIO_VAR_ENABLE_W1TC_R)

◆ GPIO_VAR_ENABLE_W1TS

#define GPIO_VAR_ENABLE_W1TS   (*GPIO_VAR_ENABLE_W1TS_R)

◆ GPIO_VAR_IN

#define GPIO_VAR_IN   (*GPIO_VAR_IN_R)

◆ IO_MUX_REG

#define IO_MUX_REG ( x)
Value:
#define XIO_MUX_REG(x)
Definition hdw-ch32v003.c:52

◆ XIO_MUX_REG

#define XIO_MUX_REG ( x)
Value:
(IO_MUX_GPIO0_REG + (x * 4))

◆ GPIO_NUM

#define GPIO_NUM ( x)
Value:
#define XGPIO_NUM(x)
Definition hdw-ch32v003.c:55

◆ XGPIO_NUM

#define XGPIO_NUM ( x)
Value:
(GPIO_NUM_0 + (x * 4))

Function Documentation

◆ uprintf()

int uprintf ( const char * fmt,
... )

vaprintf stand-in for USB logging.

Parameters
fmtvaprintf format
...vaprintf args
Returns
size Number of characters that were written.

◆ initCh32v003()

int initCh32v003 ( int swdio_pin)

◆ ch32v003WriteMemory()

int ch32v003WriteMemory ( const uint8_t * binary,
uint32_t length,
uint32_t offset )

Write to memory on the ch32v003.

Parameters
binaryA binary image to be loaded into a location in the ch32v003.
lengthThe size of the binary image.
offsetThe offset of the binary image.s

◆ ch32v003WriteFlash()

int ch32v003WriteFlash ( const uint8_t * buf,
int sz )

Write data into the ch32v003's flash.

Parameters
bufA pointer to a binary image in the master processor
szThe size of the binary image to be written
Returns
0 if OK, nonzero in error condition.

◆ ch32v003Resume()

int ch32v003Resume ( )

Cause the 003 to reboot and execute the program loaded into it.

Returns
0 if OK, nonzero in error condition.

◆ ch32v003ReadMemory()

int ch32v003ReadMemory ( uint8_t * binary,
uint32_t length,
uint32_t offset )

Read data from the ch32v003's memory space into host processor memory space.

Parameters
binaryA pointer to a buffer in the host processor
lengthThe number of bytes to read
offsetThe location of memory to read in the ch32v003
Returns
0 if OK, nonzero if error.

◆ ch32v003GetReg()

int ch32v003GetReg ( int regno,
uint32_t * value )

Read ch32v003 debug module registers.

Parameters
regnoThe debug module register number.
valueA pointer to the uint32_t to receive that register's value.
Returns
0 if OK, nonzero if error.

◆ ch32v003SetReg()

int ch32v003SetReg ( int regno,
uint32_t regValue )

Write ch32v003 debug module registers.

Parameters
regnoThe debug module register number.
regValueThe value to write into that debug module regsiter
Returns
0 if OK, nonzero if error.

◆ ch32v003CheckTerminal()

void ch32v003CheckTerminal ( )

See if the ch32v003 has any pending printf to print on host processor.

◆ ch32v003Teardown()

void ch32v003Teardown ( )

Disables ch32v003 communications.

Variable Documentation

◆ swioContext

struct SWIOState swioContext