Skip to content

Commit

Permalink
Update MOS sysvars struct (RTC, mouse) (#16)
Browse files Browse the repository at this point in the history
Update mos_api.h
  • Loading branch information
BlastBrothers authored Apr 6, 2024
1 parent 3e320ef commit 28b7b60
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
22 changes: 20 additions & 2 deletions include/mos_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Title: AGON MOS - MOS c header interface
* Author: Jeroen Venema
* Created: 15/10/2022
* Last Updated: 18/11/2023
* Last Updated: 05/04/2024
*
* Modinfo:
* 15/10/2022: Added putch, getch
Expand All @@ -14,6 +14,7 @@
* 02/07/2023: Added struct / union for RTC_DATA
* 22/07/2023: Added structure for SYSVAR
* 18/11/2023: Added mos_setkbvector, mos_getkbmap, mos_i2c_open, mos_i2c_close, mos_i2c_write, mos_i2c_read
* 05/04/2024: Added more mos sysvars, and expanded SYSVAR struct
*/

#ifndef _MOS_H
Expand Down Expand Up @@ -91,6 +92,15 @@ typedef enum {
#define sysvar_keydelay 0x22 // 2: Keyboard repeat delay
#define sysvar_keyrate 0x24 // 2: Keyboard repeat reat
#define sysvar_keyled 0x26 // 1: Keyboard LED status
//TODO: for scrMode and below, we need to write getters
#define sysvar_scrMode 0x27 // 1: Screen mode
#define sysvar_rtcEnable 0x28 // 1: RTC enable flag (0: disabled, 1: use ESP32 RTC)
#define sysvar_mouseX 0x29 // 2: Mouse X position
#define sysvar_mouseY 0x2B // 2: Mouse Y position
#define sysvar_mouseButtons 0x2D // 1: Mouse button state
#define sysvar_mouseWheel 0x2E // 1: Mouse wheel delta
#define sysvar_mouseXDelta 0x2F // 2: Mouse X delta
#define sysvar_mouseYDelta 0x31 // 2: Mouse Y delta

// Flags for the VPD protocol - sysvar_vpd_pflags
#define vdp_pflag_cursor 0x01
Expand All @@ -99,6 +109,7 @@ typedef enum {
#define vdp_pflag_audio 0x08
#define vdp_pflag_mode 0x10
#define vdp_pflag_rtc 0x20
#define vdp_pflag_mouse 0x40

// Stucture / union for accessing RTC data

Expand Down Expand Up @@ -150,6 +161,13 @@ typedef struct {
uint16_t keyrate;
uint8_t keyled;
uint8_t scrMode;
uint8_t rtcEnable;
uint16_t mouseX;
uint16_t mouseY;
uint8_t mouseButtons;
uint8_t mouseWheel;
uint16_t mouseXDelta;
uint16_t mouseYDelta;
} SYSVAR;


Expand Down Expand Up @@ -260,4 +278,4 @@ extern uint8_t mos_i2c_read(uint8_t i2c_address, uint8_t size, unsigned char *
}
#endif

#endif // _MOS_H
#endif // _MOS_H
49 changes: 47 additions & 2 deletions src/libc/include/mos_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Title: AGON MOS - MOS c header interface
* Author: Jeroen Venema
* Created: 15/10/2022
* Last Updated: 22/07/2023
* Last Updated: 05/04/2024
*
* Modinfo:
* 15/10/2022: Added putch, getch
Expand All @@ -13,6 +13,8 @@
* 19/04/2023: Added mos_getfil
* 02/07/2023: Added struct / union for RTC_DATA
* 22/07/2023: Added structure for SYSVAR
* 18/11/2023: Added mos_setkbvector, mos_getkbmap, mos_i2c_open, mos_i2c_close, mos_i2c_write, mos_i2c_read
* 05/04/2024: Added more mos sysvars, and expanded SYSVAR struct
*/

#ifndef _MOS_H
Expand All @@ -30,6 +32,17 @@ typedef uint8_t BYTE;
#define FA_OPEN_ALWAYS 0x10
#define FA_OPEN_APPEND 0x30

// I2C frequency
#define I2C_SPEED_57600 0x01
#define I2C_SPEED_115200 0x02
#define I2C_SPEED_230400 0x03
// I2C return codes to caller
#define RET_OK 0x00
#define RET_NORESPONSE 0x01
#define RET_DATA_NACK 0x02
#define RET_ARB_LOST 0x04
#define RET_BUS_ERROR 0x08

/* FatFS File function return code (FRESULT) */

typedef enum {
Expand Down Expand Up @@ -79,6 +92,15 @@ typedef enum {
#define sysvar_keydelay 0x22 // 2: Keyboard repeat delay
#define sysvar_keyrate 0x24 // 2: Keyboard repeat reat
#define sysvar_keyled 0x26 // 1: Keyboard LED status
//TODO: for scrMode and below, we need to write getters
#define sysvar_scrMode 0x27 // 1: Screen mode
#define sysvar_rtcEnable 0x28 // 1: RTC enable flag (0: disabled, 1: use ESP32 RTC)
#define sysvar_mouseX 0x29 // 2: Mouse X position
#define sysvar_mouseY 0x2B // 2: Mouse Y position
#define sysvar_mouseButtons 0x2D // 1: Mouse button state
#define sysvar_mouseWheel 0x2E // 1: Mouse wheel delta
#define sysvar_mouseXDelta 0x2F // 2: Mouse X delta
#define sysvar_mouseYDelta 0x31 // 2: Mouse Y delta

// Flags for the VPD protocol - sysvar_vpd_pflags
#define vdp_pflag_cursor 0x01
Expand All @@ -87,6 +109,7 @@ typedef enum {
#define vdp_pflag_audio 0x08
#define vdp_pflag_mode 0x10
#define vdp_pflag_rtc 0x20
#define vdp_pflag_mouse 0x40

// Stucture / union for accessing RTC data

Expand Down Expand Up @@ -138,6 +161,13 @@ typedef struct {
uint16_t keyrate;
uint8_t keyled;
uint8_t scrMode;
uint8_t rtcEnable;
uint16_t mouseX;
uint16_t mouseY;
uint8_t mouseButtons;
uint8_t mouseWheel;
uint16_t mouseXDelta;
uint16_t mouseYDelta;
} SYSVAR;


Expand Down Expand Up @@ -173,6 +203,10 @@ typedef struct {
uint24_t* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */
} FIL;

#ifdef __cplusplus
extern "C" {
#endif

// Generic IO
extern int putch(int a);
extern char getch(void);
Expand Down Expand Up @@ -233,4 +267,15 @@ extern uint24_t mos_fread(uint8_t fh, char *buffer, uint24_t numbytes);
extern uint24_t mos_fwrite(uint8_t fh, char *buffer, uint24_t numbytes);
extern uint8_t mos_flseek(uint8_t fh, uint32_t offset);
extern FIL* mos_getfil(uint8_t fh);
#endif
extern void mos_setkbvector(void(*handler)(void), uint8_t addresslength); // length 0:24bit, 1:16bit
extern uint8_t* mos_getkbmap(void); // returns address of the keyboard map
extern void mos_i2c_open(uint8_t frequency);
extern void mos_i2c_close(void);
extern uint8_t mos_i2c_write(uint8_t i2c_address, uint8_t size, unsigned char * buffer);
extern uint8_t mos_i2c_read(uint8_t i2c_address, uint8_t size, unsigned char * buffer);

#ifdef __cplusplus
}
#endif

#endif // _MOS_H

0 comments on commit 28b7b60

Please sign in to comment.