mirror of
https://github.com/pine64/blisp.git
synced 2025-03-27 08:18:57 +00:00
- Unused function warnings Move function definitions in include/blisp_util.h to lib/blisp_util.c. Defining them as static leads to internal linkage, accessible in that translation unit, hence the warning. Their references are to be handled in other translation units, so they shouldn't be static. - Unused function parameters Use C attribute `[[maybe_unused]]` (introduced in C23) to suppress unused parameter warnings. - `blisp_chip_xxxxx_get_eflash_loader` implementations accept clock type but don't use it. - `drain` function only has a body under macOS and FreeBSD with preprocessor predicates. - Enable compiler warnings Now that warnings are address enable them `-Wall -Wextra -Wpedantic` for the library and the tool targets. N.B. An equivalent of MSVC should be added to CMakeLists.txt, as these would only work when using GCC or Clang.
76 lines
2.7 KiB
C
76 lines
2.7 KiB
C
// SPDX-License-Identifier: MIT
|
|
#ifndef _LIBBLISP_H
|
|
#define _LIBBLISP_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "blisp_chip.h"
|
|
|
|
enum blisp_return {
|
|
BLISP_OK = 0,
|
|
BLISP_ERR_UNKNOWN = -1,
|
|
BLISP_ERR_NO_RESPONSE = -2,
|
|
BLISP_ERR_DEVICE_NOT_FOUND = -3,
|
|
BLISP_ERR_CANT_OPEN_DEVICE = -4,
|
|
// Can't auto-find device due it doesn't have native USB
|
|
BLISP_ERR_NO_AUTO_FIND_AVAILABLE = -5,
|
|
BLISP_ERR_PENDING = -6,
|
|
BLISP_ERR_CHIP_ERR = -7
|
|
};
|
|
|
|
struct blisp_segment_header {
|
|
uint32_t dest_addr;
|
|
uint32_t length;
|
|
uint32_t reserved;
|
|
uint32_t crc32;
|
|
};
|
|
|
|
struct blisp_device {
|
|
struct blisp_chip* chip;
|
|
void* serial_port;
|
|
bool is_usb;
|
|
uint32_t current_baud_rate;
|
|
uint8_t rx_buffer[5000]; // TODO:
|
|
uint8_t tx_buffer[5000];
|
|
uint16_t error_code;
|
|
};
|
|
|
|
struct blisp_boot_info {
|
|
uint8_t boot_rom_version[4];
|
|
uint8_t chip_id[8]; // TODO: BL60X only 6 bytes
|
|
};
|
|
|
|
// TODO: Refactor variable names, so all will follow same semantic, like
|
|
// image_run, image_check etc.
|
|
|
|
int32_t blisp_device_init(struct blisp_device* device, struct blisp_chip* chip);
|
|
int32_t blisp_device_open(struct blisp_device* device, const char* port_name);
|
|
int32_t blisp_device_handshake(struct blisp_device* device, bool in_ef_loader);
|
|
int32_t blisp_device_get_boot_info(struct blisp_device* device,
|
|
struct blisp_boot_info* boot_info);
|
|
int32_t blisp_device_load_boot_header(struct blisp_device* device,
|
|
uint8_t* boot_header);
|
|
int32_t blisp_device_load_segment_header(
|
|
struct blisp_device* device,
|
|
struct blisp_segment_header* segment_header);
|
|
int32_t blisp_device_load_segment_data(struct blisp_device* device,
|
|
uint8_t* segment_data,
|
|
uint32_t segment_data_length);
|
|
int32_t blisp_device_write_memory(struct blisp_device* device,
|
|
uint32_t address,
|
|
uint32_t value,
|
|
bool wait_for_res);
|
|
int32_t blisp_device_check_image(struct blisp_device* device);
|
|
int32_t blisp_device_run_image(struct blisp_device* device);
|
|
int32_t blisp_device_flash_erase(struct blisp_device* device,
|
|
uint32_t start_address,
|
|
uint32_t end_address);
|
|
int32_t blisp_device_flash_write(struct blisp_device* device,
|
|
uint32_t start_address,
|
|
uint8_t* payload,
|
|
uint32_t payload_size);
|
|
int32_t blisp_device_program_check(struct blisp_device* device);
|
|
int32_t blisp_device_reset(struct blisp_device* device);
|
|
void blisp_device_close(struct blisp_device* device);
|
|
#endif
|