1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-03 22:32:24 +00:00

Adding ch376.h header, correcting some bugs

This commit is contained in:
jede 2016-12-14 23:45:20 +01:00
parent 252e4afb9c
commit 15ac85b50c
2 changed files with 60 additions and 3 deletions

55
include/ch376.h Normal file
View File

@ -0,0 +1,55 @@
/* /// "Portable types" */
/* /// "CH376 interface commands and constants" */
// Chip version
#define CH376_DATA_IC_VER 3
// Commands
#define CH376_CMD_NONE 0x00
#define CH376_CMD_GET_IC_VER 0x01
#define CH376_CMD_CHECK_EXIST 0x06
#define CH376_CMD_SET_USB_MODE 0x15
#define CH376_CMD_GET_STATUS 0x22
#define CH376_CMD_RD_USB_DATA0 0x27
#define CH376_CMD_WR_REQ_DATA 0x2d
#define CH376_CMD_SET_FILE_NAME 0x2f
#define CH376_CMD_DISK_MOUNT 0x31
#define CH376_CMD_FILE_OPEN 0x32
#define CH376_CMD_FILE_ENUM_GO 0x33
#define CH376_CMD_FILE_CREATE 0x34
#define CH376_CMD_FILE_CLOSE 0x36
#define CH376_CMD_BYTE_LOCATE 0x39
#define CH376_CMD_BYTE_READ 0x3a
#define CH376_CMD_BYTE_RD_GO 0x3b
#define CH376_CMD_BYTE_WRITE 0x3c
#define CH376_CMD_BYTE_WR_GO 0x3d
#define CH376_CMD_DISK_QUERY 0x3f
#define CH376_CMD_DISK_RD_GO 0x55
#define CH376_ARG_SET_USB_MODE_INVALID 0x00
#define CH376_ARG_SET_USB_MODE_SD_HOST 0x03
#define CH376_ARG_SET_USB_MODE_USB_HOST 0x06
// Status & errors
#define CH376_ERR_OPEN_DIR 0x41
#define CH376_ERR_MISS_FILE 0x42
#define CH376_RET_SUCCESS 0x51
#define CH376_RET_ABORT 0x5f
#define CH376_INT_SUCCESS 0x14
#define CH376_INT_DISK_READ 0x1d
#define CH376_INT_DISK_WRITE 0x1e
unsigned char ch376_check_exist(unsigned char value);
unsigned char ch376_ic_get_version(void);
void ch376_set_usb_mode(unsigned char value);
unsigned char ch376_disk_mount(void);

View File

@ -4,7 +4,7 @@
.export _ch376_reset
.export _ch376_check_exist
.export _ch376_disk_mount
.export _ch376_set_usb_mode
.import popax
.importzp sp,tmp2,tmp3,tmp1
.include "telemon30.inc"
@ -123,6 +123,7 @@ loop:
.proc _ch376_ic_get_version
lda #CH376_GET_IC_VER
sta CH376_COMMAND
ldx #0
lda CH376_DATA
rts
.endproc
@ -131,10 +132,10 @@ loop:
.proc _ch376_set_usb_mode
; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY
sta tmp1
pha
lda #CH376_SET_USB_MODE ; $15
sta CH376_COMMAND
lda tmp1
pla
sta CH376_DATA
rts
.endproc
@ -169,6 +170,7 @@ loop:
sta CH376_COMMAND
jsr _ch376_wait_response
; if we read data value, we have then length of the volume name
ldx #0
rts
.endproc