|
whiskers 0.2.0
RP2350 BadUSB Tool
|
Shared structs, error codes, and functions for all HAL files.
This file contains all the defines and structs required for the rest of the HAL functions.
It also contains all HAL configuration definitions.
#include <stdint.h>#include <stddef.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | hal_file |
| File struct to be used in file operations. More... | |
| struct | hal_dir |
| Directory struct used in directory operations. More... | |
| struct | disk_info |
| Struct to hold disk information. More... | |
Macros | |
| #define | CODE_VERSION "0.2.0" |
| #define | HAL_OKAY 0 |
| Everything is A-Okay! | |
| #define | HAL_FS_DISK_ERR 1 |
| Hardware error has occured. Typically from bad configuration of device in code. | |
| #define | HAL_FS_INT_ERR 2 |
| Some sort of internal assertion failed. Not much we can do from here to be honest! | |
| #define | HAL_FS_NOT_READY 3 |
| Device not ready. Either it's broken or simply not inserted. | |
| #define | HAL_FS_NO_FILE 4 |
| Could not find the requested file. | |
| #define | HAL_FS_NO_PATH 5 |
| Could not find the requested path. | |
| #define | HAL_FS_INVALID_NAME 6 |
| File or pathname requested is not valid. | |
| #define | HAL_FS_ACCESS_DENY 7 |
| Trying to access a file or directory with wrong permissions. | |
| #define | HAL_FS_ALRDY_EXISTS 8 |
| Trying to open a file or directory that already exists. Should not typically run into this one, as the code is setup to never force open a file if it already exists. | |
| #define | HAL_FS_INVALID_OBJ 9 |
| The internal pointer to either the dir or file is not valid. | |
| #define | HAL_FS_NOT_ENABLED 10 |
| Trying to do an operation on the disk and it's not yet mounted. | |
| #define | HAL_FS_NO_FS 11 |
| Disk mounted but not FatFS found. | |
| #define | HAL_FS_MKFS_ABORTED 12 |
| ffmkfs() failed for an undetermined reason. Either the drive is broken or wrong parameters were passed in. | |
| #define | HAL_FS_TIMEOUT 13 |
| One of the file functions timed out. This typically does not ever occur as timeouts are not setup. | |
| #define | HAL_FS_LOCKED 14 |
| Attemping to access a file that is already open or is having active writes to. | |
| #define | HAL_FS_NOT_ENOUGH_M 15 |
| Not enough memory is left over for the internal code to work. | |
| #define | HAL_FS_TOO_MANY_OPN 16 |
| Too many files or directories opened at once. The limit is determined in this file by the HAL_FS_MAX_OPEN_* defines. | |
| #define | HAL_FS_INVALID_PARM 17 |
| Invalid paramter passed into function. | |
| #define | HAL_FS_WRITE_PROT 18 |
| Trying to write to either a write-protected medium or a non write-opened file. | |
| #define | HAL_FS_INVALID_DRIV 19 |
| Drive provided either does not exist or will not work. | |
| #define | HAL_FS_DOUBLE_OPEN 20 |
| Trying to open a file or directory on an already opened file structure. | |
| #define | HAL_FS_UNKNOWN_ERR 21 |
| Catchall incase some wild/weird error is thrown. | |
| #define | HAL_FLASH_OUT_OF_BOUNDS 22 |
| Requested page or sector is out of bounds of available memory. | |
| #define | HAL_FLASH_BAD_INTEGRITY 23 |
| Page/Sector failed integrity check. | |
| #define | HAL_USB_CANNOT_INITIALIZE 24 |
| TinyUSB stack failed to launch. This usually indicates bad parameters or an underlying problem with the USB controller. | |
| #define | HAL_FS_MAX_OPEN_FILES 16 |
| Determines how many files are allowed to be open on the device. | |
| #define | HAL_FS_MAX_OPEN_DIRS 4 |
| Determines how many directories are allowed to be open on the device. | |
| #define | HAL_SD_USE_HW_CD false |
| If false, the SD library will internally check for whether the SD is mounted. If true the chip-detect switch on the board will be used. | |
Typedefs | |
| typedef uint8_t | HAL_ERROR |
| This type represents a HAL_* error. See the defines in the file to read up on them. | |
| typedef struct hal_file | _FILE |
| typedef struct hal_dir | _DIR |
| typedef struct disk_info | _DISK_INFO |
Functions | |
| const char * | HAL_ERROR_to_str (HAL_ERROR errno) |
| Turns provided errno into a string for logging/debugging. | |
| #define HAL_FS_MAX_OPEN_DIRS 4 |
Determines how many directories are allowed to be open on the device.
| #define HAL_FS_MAX_OPEN_FILES 16 |
Determines how many files are allowed to be open on the device.
Do note that internally all files are fully initialized with their work areas. This means that the more that is allowed to open the more memory is used regardless of state. This is determined by what sized work buffer is needed for the underlying filesystem and is implementation dependant. Try to leave this to as low as possible.
| #define HAL_SD_USE_HW_CD false |
If false, the SD library will internally check for whether the SD is mounted. If true the chip-detect switch on the board will be used.
Note for board version(s) 1.0 this is best set to false. This is because for some reason (likely due to the low cost of the SD card slots) the hardware chip-detect switch is not accurate/does not work at all.