whiskers
0.4.0
RP2350 BadUSB Tool
Toggle main menu visibility
Loading...
Searching...
No Matches
shared.h
Go to the documentation of this file.
1
/* Copyright (c) 2026 Zane A. Maple
2
Licensed under the MIT license. See LICENSE in the main repository for more information. */
3
4
/* Includes standard struct definitions to be used across hardware implementations */
5
15
16
#ifndef W_HAL_SHARED_H
17
#define W_HAL_SHARED_H
18
19
#include <stdint.h>
20
#include <stddef.h>
21
#include <stdbool.h>
22
23
/* Note: these are not set in stone and will be expanded upon more than likely as time goes on */
28
typedef
uint8_t
HAL_ERROR
;
29
#define HAL_OKAY 0
34
#define HAL_FS_DISK_ERR 1
39
#define HAL_FS_INT_ERR 2
44
#define HAL_FS_NOT_READY 3
49
#define HAL_FS_NO_FILE 4
54
#define HAL_FS_NO_PATH 5
59
#define HAL_FS_INVALID_NAME 6
64
#define HAL_FS_ACCESS_DENY 7
69
#define HAL_FS_ALRDY_EXISTS 8
74
#define HAL_FS_INVALID_OBJ 9
79
#define HAL_FS_NOT_ENABLED 10
84
#define HAL_FS_NO_FS 11
89
#define HAL_FS_MKFS_ABORTED 12
94
#define HAL_FS_TIMEOUT 13
99
#define HAL_FS_LOCKED 14
104
#define HAL_FS_NOT_ENOUGH_M 15
109
#define HAL_FS_TOO_MANY_OPN 16
114
#define HAL_FS_INVALID_PARM 17
119
#define HAL_FS_WRITE_PROT 18
124
#define HAL_FS_INVALID_DRIV 19
129
#define HAL_FS_DOUBLE_OPEN 20
134
#define HAL_FS_UNKNOWN_ERR 21
139
140
#define HAL_FLASH_OUT_OF_BOUNDS 22
145
#define HAL_FLASH_BAD_INTEGRITY 23
150
#define HAL_USB_CANNOT_INITIALIZE 24
155
#define HAL_FS_READDIR_RESET 25
160
/* File system settings */
161
162
#define HAL_FS_MAX_OPEN_FILES 16
170
#define HAL_FS_MAX_OPEN_DIRS 4
176
#define HAL_SD_USE_HW_CD false
183
198
typedef
struct
hal_file
199
{
200
/* Basic metadata */
201
char
*
filename
;
202
size_t
fsize
;
203
uint8_t
fattrs
;
204
uint16_t
fdate
;
205
uint16_t
ftime
;
206
uint32_t
fd
;
207
208
/* Internal pointer based on underlying implementation, points to actual internal file object */
209
void
*
_internal_fp
;
210
bool
_internal_has_file
;
211
212
/* If any of the file functions fail, this is where the err is set */
213
HAL_ERROR
errno
;
214
} _FILE;
215
230
typedef
struct
hal_dir
231
{
232
uint8_t
dattrs
;
233
uint16_t
fdate
;
234
uint16_t
ftime
;
235
uint32_t
dd
;
236
237
/* Internal pointer based on underlying implementation, points to actual internal dir object */
238
void
*
_internal_dp
;
239
bool
_internal_has_dir
;
240
241
/* If any of the file functions fail, this is where the err is set */
242
HAL_ERROR
errno
;
243
} _DIR;
244
253
254
/* Mainly used as an pointer holder for internal sd/fatfs code */
255
typedef
struct
disk_info
256
{
257
bool
disk_mounted
;
258
bool
is_externally_writable
;
260
void
*
_internal_sdp
;
261
void
*
_internal_fsp
;
262
bool (*
_internal_read_fp
)(uint32_t, uint32_t,
void
*);
263
bool (*
_internal_write_fp
)(uint32_t, uint32_t, uint8_t*);
264
uint32_t
_internal_blocksize
;
265
uint32_t
_internal_sectorcount
;
266
267
268
/* Errno for all disk operations */
269
HAL_ERROR
errno
;
270
271
} _DISK_INFO;
272
278
const
char
* HAL_ERROR_to_str(
HAL_ERROR
errno);
279
280
#endif
HAL_ERROR
uint8_t HAL_ERROR
This type represents a HAL_* error. See the defines in the file to read up on them.
Definition
shared.h:28
disk_info
Struct to hold disk information.
Definition
shared.h:256
disk_info::_internal_blocksize
uint32_t _internal_blocksize
Definition
shared.h:264
disk_info::is_externally_writable
bool is_externally_writable
Definition
shared.h:258
disk_info::_internal_write_fp
bool(*) _internal_write_fp(uint32_t, uint32_t, uint8_t *)
Definition
shared.h:263
disk_info::_internal_fsp
void * _internal_fsp
Definition
shared.h:261
disk_info::_internal_sdp
void * _internal_sdp
Definition
shared.h:260
disk_info::errno
HAL_ERROR errno
Definition
shared.h:269
disk_info::_internal_read_fp
bool(*) _internal_read_fp(uint32_t, uint32_t, void *)
Definition
shared.h:262
disk_info::_internal_sectorcount
uint32_t _internal_sectorcount
Definition
shared.h:265
disk_info::disk_mounted
bool disk_mounted
Definition
shared.h:257
hal_dir
Directory struct used in directory operations.
Definition
shared.h:231
hal_dir::errno
HAL_ERROR errno
Definition
shared.h:242
hal_dir::_internal_has_dir
bool _internal_has_dir
Definition
shared.h:239
hal_dir::fdate
uint16_t fdate
Definition
shared.h:233
hal_dir::dd
uint32_t dd
Definition
shared.h:235
hal_dir::_internal_dp
void * _internal_dp
Definition
shared.h:238
hal_dir::ftime
uint16_t ftime
Definition
shared.h:234
hal_dir::dattrs
uint8_t dattrs
Definition
shared.h:232
hal_file
File struct to be used in file operations.
Definition
shared.h:199
hal_file::_internal_fp
void * _internal_fp
Definition
shared.h:209
hal_file::filename
char * filename
Definition
shared.h:201
hal_file::fattrs
uint8_t fattrs
Definition
shared.h:203
hal_file::fd
uint32_t fd
Definition
shared.h:206
hal_file::ftime
uint16_t ftime
Definition
shared.h:205
hal_file::errno
HAL_ERROR errno
Definition
shared.h:213
hal_file::fdate
uint16_t fdate
Definition
shared.h:204
hal_file::_internal_has_file
bool _internal_has_file
Definition
shared.h:210
hal_file::fsize
size_t fsize
Definition
shared.h:202
code
hal
shared.h
Generated by
1.18.0