llvm-mos-sdk
uext.h
Go to the documentation of this file.
1 // Copyright 2024 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 #include <stdint.h>
7 
8 #ifndef _NEO_UEXT_H
9 #define _NEO_UEXT_H
10 
11 #include <neo6502.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 typedef enum neo_uext_direction {
22 
28 void neo_uext_init(void);
29 
37 void neo_uext_gpio_write(uint8_t pin, uint8_t value);
38 
48 
56 void neo_uext_gpio_set_direction(uint8_t pin, uint8_t direction);
57 
63 void neo_uext_i2c_write(uint8_t device, uint8_t reg, uint8_t value);
64 
71 
78 
87 
93 void neo_uext_i2c_block_read(uint8_t device, void *dest, uint16_t len);
94 
100 void neo_uext_i2c_block_write(uint8_t device, const void *src, uint16_t len);
101 
107 void neo_uext_spi_block_read(uint8_t device, void *dest, uint16_t len);
108 
114 void neo_uext_spi_block_write(uint8_t device, const void *src, uint16_t len);
115 
121 void neo_uext_uart_block_read(uint8_t device, void *dest, uint16_t len);
122 
128 void neo_uext_uart_block_write(uint8_t device, const void *src, uint16_t len);
129 
130 #define NEO_UART_PROTOCOL_8N1 0
131 
135 void neo_uext_uart_configure(uint32_t baudrate, uint8_t protocol);
136 
140 void neo_uext_uart_write(uint8_t value);
141 
146 
150 bool neo_uext_uart_available(void);
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif
neo_uext_init
void neo_uext_init(void)
Initialise the UExt I/O system.
neo_uext_uart_configure
void neo_uext_uart_configure(uint32_t baudrate, uint8_t protocol)
Configure the UART baud rate and protocol.
std::uint16_t
::uint16_t uint16_t
Definition: cstdint:22
neo_uext_spi_block_read
void neo_uext_spi_block_read(uint8_t device, void *dest, uint16_t len)
Read a block from an SPI device.
neo_uext_i2c_block_read
void neo_uext_i2c_block_read(uint8_t device, void *dest, uint16_t len)
Read a block from an I2C device.
neo_uext_uart_available
bool neo_uext_uart_available(void)
Check if a byte can be read from UART.
neo_uext_spi_block_write
void neo_uext_spi_block_write(uint8_t device, const void *src, uint16_t len)
Write a block to an SPI device.
neo_uext_direction
neo_uext_direction
Definition: uext.h:17
neo_uext_gpio_write
void neo_uext_gpio_write(uint8_t pin, uint8_t value)
Write the specified value to the output latch for the specified UEXT pin.
std::uint8_t
::uint8_t uint8_t
Definition: cstdint:21
neo_uext_gpio_set_direction
void neo_uext_gpio_set_direction(uint8_t pin, uint8_t direction)
Set the direction of the specified UEXT pin.
neo_uext_i2c_block_write
void neo_uext_i2c_block_write(uint8_t device, const void *src, uint16_t len)
Write a block to an I2C device.
neo_uext_analogue_read
uint16_t neo_uext_analogue_read(uint8_t pin)
Read from an analogue input pin.
NEO_UEXT_ANALOGUE_INPUT
@ NEO_UEXT_ANALOGUE_INPUT
Definition: uext.h:20
src
const void * src
Definition: memory.h:57
neo_uext_uart_write
void neo_uext_uart_write(uint8_t value)
Write a byte to UART.
neo_uext_uart_read
uint8_t neo_uext_uart_read(void)
Read a byte from UART.
neo6502.h
neo_uext_i2c_write
void neo_uext_i2c_write(uint8_t device, uint8_t reg, uint8_t value)
Write to an I2C device.
neo_uext_i2c_status
uint8_t neo_uext_i2c_status(uint8_t device)
Query the I2C device status.
neo_uext_i2c_read
uint8_t neo_uext_i2c_read(uint8_t device, uint8_t reg)
Read from an I2C device.
NEO_UEXT_INPUT
@ NEO_UEXT_INPUT
Definition: uext.h:18
std::uint32_t
::uint32_t uint32_t
Definition: cstdint:23
neo_uext_direction_t
enum neo_uext_direction neo_uext_direction_t
neo_uext_gpio_read
uint8_t neo_uext_gpio_read(uint8_t pin)
Reads the value on the specified UEXT pin.
NEO_UEXT_OUTPUT
@ NEO_UEXT_OUTPUT
Definition: uext.h:19
neo_uext_uart_block_write
void neo_uext_uart_block_write(uint8_t device, const void *src, uint16_t len)
Write a block to an UART device.
neo_uext_uart_block_read
void neo_uext_uart_block_read(uint8_t device, void *dest, uint16_t len)
Read a block from an UART device.
len
char len
Definition: nesdoug.h:26