Browse Source

ch376-native: cleaned up formatting for ch376inc.h

pull/592/head
Dean Netherton 9 months ago
parent
commit
580d7761e1
  1. 5
      .vscode/settings.json
  2. 66
      Source/HBIOS/ch376-native/base-drv/ch376.c.s
  3. 1
      Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c
  4. 132
      Source/HBIOS/ch376-native/source-doc/base-drv/ch376inc.h
  5. 2
      Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c
  6. 2
      Source/HBIOS/ez80instr.inc

5
.vscode/settings.json

@ -10,6 +10,7 @@
"*.mac": "z80-macroasm",
"*.asmpp": "z80-macroasm",
"*.zdsproj": "xml",
"*.Z80": "z80-macroasm",
"ch376.h": "c",
"protocol.h": "c",
"usb_state.h": "c",
@ -18,6 +19,8 @@
"z80.h": "c",
"dev_transfers.h": "c",
"usb-base-drv.h": "c",
"critical-section.h": "c"
"critical-section.h": "c",
"enumerate.h": "c",
"ch376inc.h": "c"
}
}

66
Source/HBIOS/ch376-native/base-drv/ch376.c.s

@ -581,7 +581,7 @@ l_ch_data_in_transfer_00111:
;source-doc/base-drv/ch376.c:187: }
pop ix
ret
;source-doc/base-drv/ch376.c:189: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) {
;source-doc/base-drv/ch376.c:190: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) {
; ---------------------------------
; Function ch_data_in_transfer_n
; ---------------------------------
@ -589,20 +589,20 @@ _ch_data_in_transfer_n:
push ix
ld ix,0
add ix,sp
;source-doc/base-drv/ch376.c:193: USB_MODULE_LEDS = 0x01;
;source-doc/base-drv/ch376.c:194: USB_MODULE_LEDS = 0x01;
ld a,0x01
ld bc,_USB_MODULE_LEDS
out (c), a
;source-doc/base-drv/ch376.c:195: ch_issue_token_in(endpoint);
;source-doc/base-drv/ch376.c:196: ch_issue_token_in(endpoint);
ld l,(ix+8)
ld h,(ix+9)
call _ch_issue_token_in
;source-doc/base-drv/ch376.c:197: CHECK(ch_long_wait_int_and_get_status());
;source-doc/base-drv/ch376.c:198: CHECK(ch_long_wait_int_and_get_status());
call _ch_long_wait_int_and_get_statu
ld a,l
or a
jr NZ,l_ch_data_in_transfer_n_00103
;source-doc/base-drv/ch376.c:199: endpoint->toggle = !endpoint->toggle;
;source-doc/base-drv/ch376.c:200: endpoint->toggle = !endpoint->toggle;
ld l,(ix+8)
ld h,(ix+9)
ld a, (hl)
@ -614,33 +614,33 @@ _ch_data_in_transfer_n:
and 0xfe
or c
ld (hl), a
;source-doc/base-drv/ch376.c:201: count = ch_read_data(buffer);
;source-doc/base-drv/ch376.c:202: count = ch_read_data(buffer);
ld l,(ix+4)
ld h,(ix+5)
call _ch_read_data
;source-doc/base-drv/ch376.c:203: *buffer_size = count;
;source-doc/base-drv/ch376.c:204: *buffer_size = count;
ld c,(ix+6)
ld b,(ix+7)
ld (bc), a
;source-doc/base-drv/ch376.c:205: USB_MODULE_LEDS = 0x00;
;source-doc/base-drv/ch376.c:206: USB_MODULE_LEDS = 0x00;
ld a,0x00
ld bc,_USB_MODULE_LEDS
out (c), a
;source-doc/base-drv/ch376.c:207: return USB_ERR_OK;
;source-doc/base-drv/ch376.c:208: return USB_ERR_OK;
ld l,0x00
jr l_ch_data_in_transfer_n_00104
;source-doc/base-drv/ch376.c:208: done:
;source-doc/base-drv/ch376.c:209: done:
l_ch_data_in_transfer_n_00103:
;source-doc/base-drv/ch376.c:209: USB_MODULE_LEDS = 0x00;
;source-doc/base-drv/ch376.c:210: USB_MODULE_LEDS = 0x00;
ld a,0x00
ld bc,_USB_MODULE_LEDS
out (c), a
;source-doc/base-drv/ch376.c:210: return result;
;source-doc/base-drv/ch376.c:211: return result;
l_ch_data_in_transfer_n_00104:
;source-doc/base-drv/ch376.c:211: }
;source-doc/base-drv/ch376.c:212: }
pop ix
ret
;source-doc/base-drv/ch376.c:213: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) {
;source-doc/base-drv/ch376.c:214: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) {
; ---------------------------------
; Function ch_data_out_transfer
; ---------------------------------
@ -649,7 +649,7 @@ _ch_data_out_transfer:
ld ix,0
add ix,sp
dec sp
;source-doc/base-drv/ch376.c:216: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex);
;source-doc/base-drv/ch376.c:217: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex);
ld c,(ix+8)
ld b,(ix+9)
ld e, c
@ -657,13 +657,13 @@ _ch_data_out_transfer:
inc de
ld a, (de)
ld (ix-1),a
;source-doc/base-drv/ch376.c:218: USB_MODULE_LEDS = 0x02;
;source-doc/base-drv/ch376.c:219: USB_MODULE_LEDS = 0x02;
ld a,0x02
push bc
ld bc,_USB_MODULE_LEDS
out (c), a
pop bc
;source-doc/base-drv/ch376.c:220: while (buffer_length > 0) {
;source-doc/base-drv/ch376.c:221: while (buffer_length > 0) {
l_ch_data_out_transfer_00103:
xor a
cp (ix+6)
@ -672,7 +672,7 @@ l_ch_data_out_transfer_00103:
xor 0x80
l_ch_data_out_transfer_00139:
jp P, l_ch_data_out_transfer_00105
;source-doc/base-drv/ch376.c:221: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length;
;source-doc/base-drv/ch376.c:222: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length;
ld d,(ix-1)
ld e,0x00
ld a, d
@ -688,7 +688,7 @@ l_ch_data_out_transfer_00109:
ld d,(ix+6)
ld e,(ix+7)
l_ch_data_out_transfer_00110:
;source-doc/base-drv/ch376.c:222: buffer = ch_write_data(buffer, size);
;source-doc/base-drv/ch376.c:223: buffer = ch_write_data(buffer, size);
push bc
push de
push de
@ -703,7 +703,7 @@ l_ch_data_out_transfer_00110:
pop bc
ld (ix+4),l
ld (ix+5),h
;source-doc/base-drv/ch376.c:223: buffer_length -= size;
;source-doc/base-drv/ch376.c:224: buffer_length -= size;
ld e,0x00
ld a,(ix+6)
sub d
@ -711,19 +711,19 @@ l_ch_data_out_transfer_00110:
ld a,(ix+7)
sbc a, e
ld (ix+7),a
;source-doc/base-drv/ch376.c:224: ch_issue_token_out(endpoint);
;source-doc/base-drv/ch376.c:225: ch_issue_token_out(endpoint);
ld l,c
ld h,b
push hl
call _ch_issue_token_out
;source-doc/base-drv/ch376.c:226: CHECK(ch_long_wait_int_and_get_status());
;source-doc/base-drv/ch376.c:227: CHECK(ch_long_wait_int_and_get_status());
call _ch_long_wait_int_and_get_statu
ld a, l
pop bc
ld l, a
or a
jr NZ,l_ch_data_out_transfer_00106
;source-doc/base-drv/ch376.c:228: endpoint->toggle = !endpoint->toggle;
;source-doc/base-drv/ch376.c:229: endpoint->toggle = !endpoint->toggle;
ld e, c
ld d, b
ld l, e
@ -739,40 +739,40 @@ l_ch_data_out_transfer_00110:
ld (de), a
jr l_ch_data_out_transfer_00103
l_ch_data_out_transfer_00105:
;source-doc/base-drv/ch376.c:231: USB_MODULE_LEDS = 0x00;
;source-doc/base-drv/ch376.c:232: USB_MODULE_LEDS = 0x00;
ld a,0x00
ld bc,_USB_MODULE_LEDS
out (c), a
;source-doc/base-drv/ch376.c:232: return USB_ERR_OK;
;source-doc/base-drv/ch376.c:233: return USB_ERR_OK;
ld l,0x00
jr l_ch_data_out_transfer_00107
;source-doc/base-drv/ch376.c:234: done:
;source-doc/base-drv/ch376.c:235: done:
l_ch_data_out_transfer_00106:
;source-doc/base-drv/ch376.c:235: USB_MODULE_LEDS = 0x00;
;source-doc/base-drv/ch376.c:236: USB_MODULE_LEDS = 0x00;
ld a,0x00
ld bc,_USB_MODULE_LEDS
out (c), a
;source-doc/base-drv/ch376.c:236: return result;
;source-doc/base-drv/ch376.c:237: return result;
l_ch_data_out_transfer_00107:
;source-doc/base-drv/ch376.c:237: }
;source-doc/base-drv/ch376.c:238: }
inc sp
pop ix
ret
;source-doc/base-drv/ch376.c:239: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall {
;source-doc/base-drv/ch376.c:240: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall {
; ---------------------------------
; Function ch_set_usb_address
; ---------------------------------
_ch_set_usb_address:
;source-doc/base-drv/ch376.c:240: ch_command(CH_CMD_SET_USB_ADDR);
;source-doc/base-drv/ch376.c:241: ch_command(CH_CMD_SET_USB_ADDR);
push hl
ld l,0x13
call _ch_command
pop hl
;source-doc/base-drv/ch376.c:241: CH376_DATA_PORT = device_address;
;source-doc/base-drv/ch376.c:242: CH376_DATA_PORT = device_address;
ld a, l
ld bc,_CH376_DATA_PORT
out (c), a
;source-doc/base-drv/ch376.c:242: }
;source-doc/base-drv/ch376.c:243: }
ret
_result:
DEFB +0x00

1
Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c

@ -186,6 +186,7 @@ done:
return result;
}
//TODO: review: does buffer_size need to be signed?
usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) {
uint8_t count;
usb_error result;

132
Source/HBIOS/ch376-native/source-doc/base-drv/ch376inc.h

@ -759,49 +759,53 @@ typedef unsigned char volatile *PUINT8V;
/* The following status codes are used for file system error codes in host file
* mode */
#ifndef ERR_DISK_DISCON
#define ERR_DISK_DISCON \
0x82 /* The disk has not been connected, maybe the disk has been \
disconnected */
#define ERR_LARGE_SECTOR \
0x84 /*The sector of the disk is too large, only 512 bytes per sector are \
supported */ \
#define ERR_TYPE_ERROR 0x92 /* The disk partition type is not \
supported, only FAT12/FAT16/BigDOS/FAT32 is \
supported, it needs to be re-partitioned by the \
disk management tool */
#define ERR_BPB_ERROR \
0xA1 /*The disk has not been formatted, \
or the parameters are wrong and need to be reformatted by WINDOWS with \
default parameters */ \
#define ERR_DISK_FULL 0xB1 /*The disk file is too full, the remaining \
space is too little or there is no more, and \
disk defragmentation is required */ \
#define ERR_FDT_OVER 0xB2 /*There are too many files in the \
directory(folder), there is no free directory \
entry, the number of files in the FAT12 / \
FAT16 root directory should be less than 512, \
and disk defragmentation is required */ \
#define ERR_FILE_CLOSE 0xB4 /*The file has been closed, it should be \
reopened if needed */ \
#define ERR_OPEN_DIR 0x41 /* The directory (folder) of the specified \
path is opened */
#define ERR_MISS_FILE \
0x42 /*The file in the specified path is not found, maybe the file name is \
wrong */ \
#define ERR_FOUND_NAME 0x43 /* Search for a matching file name, or ask \
to open a directory (folder) but the actual result opens the file */
/* The disk has not been connected, maybe the disk has been disconnected */
#define ERR_DISK_DISCON 0x82
/*The sector of the disk is too large, only 512 bytes per sector are supported */
#define ERR_LARGE_SECTOR 0x84
/* The disk partition type is not supported, only FAT12/FAT16/BigDOS/FAT32 is supported, it needs to be re-partitioned by the disk
* management tool */
#define ERR_TYPE_ERROR 0x92
/* The disk has not been formatted, or the parameters are wrong and need to be reformatted by WINDOWS with default parameters */
#define ERR_BPB_ERROR 0xA1
/* The disk file is too full, the remaining space is too little or there is no more, and disk defragmentation is required */
#define ERR_DISK_FULL 0xB1
/* There are too many files in the directory(folder), there is no free directory entry, the number of files in the FAT12 / FAT16
* root directory should be less than 512, and disk defragmentation is required */
#define ERR_FDT_OVER 0xB2
/*The file has been closed, it should be reopened if needed */
#define ERR_FILE_CLOSE 0xB4
/* The directory (folder) of the specified path is opened */
#define ERR_OPEN_DIR 0x41
/* The file in the specified path is not found, maybe the file name is wrong */
#define ERR_MISS_FILE 0x42
/* Search for a matching file name, or ask to open a directory (folder) but the actual result opens the file */
/* The following file system error codes are used for file system subroutines */
#define ERR_MISS_DIR \
0xB3 /*A subdirectory(folder) of the specified path is not found, maybe the \
directory name is wrong */ \
#define ERR_LONG_BUF_OVER 0x48 /* long file buffer overflow */
#define ERR_LONG_NAME_ERR \
0x49 /* The short file name does not have a corresponding long file name or \
* the long file name is wrong \
*/
#define ERR_NAME_EXIST \
0x4A /* A short file with the same name already exists, it is recommended to \
regenerate another short file name */
#define ERR_FOUND_NAME 0x43
/* A subdirectory(folder) of the specified path is not found, maybe the directory name is wrong */
#define ERR_MISS_DIR 0xB3
/* long file buffer overflow */
#define ERR_LONG_BUF_OVER 0x48
/* The short file name does not have a corresponding long file name or the long file name is wrong */
#define ERR_LONG_NAME_ERR 0x49
/* A short file with the same name already exists, it is recommended to regenerate another short file name */
#define ERR_NAME_EXIST 0x4A
#endif
/* ************************************************
@ -809,23 +813,30 @@ typedef unsigned char volatile *PUINT8V;
/* The following status codes are used for disk and file status in host file
* mode, VAR_DISK_STATUS */
#ifndef DEF_DISK_UNKNOWN
#define DEF_DISK_UNKNOWN \
0x00 /*Not initialized, unknown state */ \
#define DEF_DISK_DISCONN 0x01 /* The disk is not connected or has been \
disconnected */
#define DEF_DISK_CONNECT \
0x02 /* The disk is connected, but it has not been initialized or the disk \
* cannot be recognized \
*/
#define DEF_DISK_MOUNTED \
0x03 /* The disk has been initialized successfully, but the file system has \
not been analyzed or the file system does not support */
#define DEF_DISK_READY 0x10 /* The file system of the disk has been analyzed and can support */
#define DEF_DISK_OPEN_ROOT \
0x12 /* The root directory has been opened and must be closed after use. \
Note that the FAT12/FAT16 root directory is a fixed length */
#define DEF_DISK_OPEN_DIR 0x13 /* A subdirectory (folder) has been opened */
#define DEF_DISK_OPEN_FILE 0x14 /* The file has been opened */
/*Not initialized, unknown state */
#define DEF_DISK_UNKNOWN 0x00
/* The disk is not connected or has been disconnected */
#define DEF_DISK_DISCONN 0x01
/* The disk is connected, but it has not been initialized or the disk cannot be recognized */
#define DEF_DISK_CONNECT 0x02
/* The disk has been initialized successfully, but the file system has not been analyzed or the file system does not support */
#define DEF_DISK_MOUNTED 0x03
/* The file system of the disk has been analyzed and can support */
#define DEF_DISK_READY 0x10
/* The root directory has been opened and must be closed after use. Note that the FAT12/FAT16 root directory is a fixed length */
#define DEF_DISK_OPEN_ROOT 0x12
/* A subdirectory (folder) has been opened */
#define DEF_DISK_OPEN_DIR 0x13
/* The file has been opened */
#define DEF_DISK_OPEN_FILE 0x14
#endif
/* ************************************************
@ -833,7 +844,8 @@ typedef unsigned char volatile *PUINT8V;
/* Common definitions of file system */
#ifndef DEF_SECTOR_SIZE
#define DEF_SECTOR_SIZE 512 /* The default physical sector size of U disk or SD card */
/* The default physical sector size of U disk or SD card */
#define DEF_SECTOR_SIZE 512
#endif
#ifndef DEF_WILDCARD_CHAR

2
Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c

@ -159,7 +159,7 @@ usb_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, const uint8_
ch_set_usb_address(device_address);
result = ch_data_in_transfer_n(buffer, buffer_size, endpoint);
result = ch_data_in_transfer_n(buffer, buffer_size, endpoint); //does ch_data_in_transfer_n size need to be signed?
critical_end();

2
Source/HBIOS/ez80instr.inc

@ -47,6 +47,8 @@
#DEFINE EZ80_TMR_IS_TICK_ISR LD A, 2 \ LD B, 10 \ EZ80_FN
#DEFINE EZ80_TMR_DELAY LD A, 2 \ LD B, 11 \ EZ80_FN
#DEFINE EZ80_EX_USB_INIT LD A, 6 \ LD B, 0 \ EZ80_FN
#DEFINE EZ80_THROTTLE_START(p,store) \
#DEFCONT \ PUSH AF
#DEFCONT \ PUSH BC

Loading…
Cancel
Save