whiskers 0.4.0
RP2350 BadUSB Tool
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 */
28typedef 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
198typedef 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 */
211
212 /* If any of the file functions fail, this is where the err is set */
214} _FILE;
215
230typedef 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 */
240
241 /* If any of the file functions fail, this is where the err is set */
243} _DIR;
244
253
254/* Mainly used as an pointer holder for internal sd/fatfs code */
255typedef struct disk_info
256{
262 bool (*_internal_read_fp)(uint32_t, uint32_t, void*);
263 bool (*_internal_write_fp)(uint32_t, uint32_t, uint8_t*);
266
267
268 /* Errno for all disk operations */
270
271} _DISK_INFO;
272
278const char * HAL_ERROR_to_str(HAL_ERROR errno);
279
280#endif
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
Struct to hold disk information.
Definition shared.h:256
uint32_t _internal_blocksize
Definition shared.h:264
bool is_externally_writable
Definition shared.h:258
bool(*) _internal_write_fp(uint32_t, uint32_t, uint8_t *)
Definition shared.h:263
void * _internal_fsp
Definition shared.h:261
void * _internal_sdp
Definition shared.h:260
HAL_ERROR errno
Definition shared.h:269
bool(*) _internal_read_fp(uint32_t, uint32_t, void *)
Definition shared.h:262
uint32_t _internal_sectorcount
Definition shared.h:265
bool disk_mounted
Definition shared.h:257
Directory struct used in directory operations.
Definition shared.h:231
HAL_ERROR errno
Definition shared.h:242
bool _internal_has_dir
Definition shared.h:239
uint16_t fdate
Definition shared.h:233
uint32_t dd
Definition shared.h:235
void * _internal_dp
Definition shared.h:238
uint16_t ftime
Definition shared.h:234
uint8_t dattrs
Definition shared.h:232
File struct to be used in file operations.
Definition shared.h:199
void * _internal_fp
Definition shared.h:209
char * filename
Definition shared.h:201
uint8_t fattrs
Definition shared.h:203
uint32_t fd
Definition shared.h:206
uint16_t ftime
Definition shared.h:205
HAL_ERROR errno
Definition shared.h:213
uint16_t fdate
Definition shared.h:204
bool _internal_has_file
Definition shared.h:210
size_t fsize
Definition shared.h:202