first commit for opensource

first commit for opensource
This commit is contained in:
supowang
2019-09-16 13:19:50 +08:00
parent 08ab013b8e
commit edb2879617
6303 changed files with 5472815 additions and 23 deletions

View File

@@ -0,0 +1,9 @@
#ifndef _TOS_HAL_H_
#define _TOS_HAL_H_
#include "tos.h"
#include "tos_hal_sd.h"
#include "tos_hal_uart.h"
#endif

View File

@@ -0,0 +1,49 @@
#ifndef _TOS_HAL_SD_H_
#define _TOS_HAL_SD_H_
typedef enum hal_sd_state_en {
HAL_SD_STAT_RESET, /*< not yet initialized or disabled */
HAL_SD_STAT_READY, /*< initialized and ready for use */
HAL_SD_STAT_TIMEOUT, /*< timeout state */
HAL_SD_STAT_BUSY, /*< process ongoing */
HAL_SD_STAT_PROGRAMMING, /*< programming state */
HAL_SD_STAT_RECEIVING, /*< receinving state */
HAL_SD_STAT_TRANSFER, /*< transfert state */
HAL_SD_STAT_ERROR, /*< error state */
} hal_sd_state_t;
typedef struct hal_sd_info_st {
uint32_t card_type; /*< card type */
uint32_t card_version; /*< card version */
uint32_t class; /*< card class */
uint32_t relative_card_addr; /*< relative card address */
uint32_t blk_num; /*< card capacity in blocks */
uint32_t blk_size; /*< one block size in bytes */
uint32_t logical_blk_num; /*< card logical capacity in blocks */
uint32_t logical_blk_size; /*< logical block size in bytes */
} hal_sd_info_t;
typedef struct hal_sd_st {
void *private_sd;
} hal_sd_t;
__API__ int tos_hal_sd_init(hal_sd_t *sd);
__API__ int tos_hal_sd_read(hal_sd_t *sd, uint8_t *buf, uint32_t blk_addr, uint32_t blk_num, uint32_t timeout);
__API__ int tos_hal_sd_write(hal_sd_t *sd, const uint8_t *buf, uint32_t blk_addr, uint32_t blk_num, uint32_t timeout);
__API__ int tos_hal_sd_read_dma(hal_sd_t *sd, uint8_t *buf, uint32_t blk_addr, uint32_t blk_num);
__API__ int tos_hal_sd_write_dma(hal_sd_t *sd, const uint8_t *buf, uint32_t blk_addr, uint32_t blk_num);
__API__ int tos_hal_sd_erase(hal_sd_t *sd, uint32_t blk_add_start, uint32_t blk_addr_end);
__API__ int tos_hal_sd_info_get(hal_sd_t *sd, hal_sd_info_t *info);
__API__ int tos_hal_sd_state_get(hal_sd_t *sd, hal_sd_state_t *state);
__API__ int tos_hal_sd_deinit(hal_sd_t *sd);
#endif

View File

@@ -0,0 +1,28 @@
#ifndef _TOS_HAL_UART_H_
#define _TOS_HAL_UART_H_
typedef enum hal_uart_port_en {
HAL_UART_PORT_0 = 0,
HAL_UART_PORT_1,
HAL_UART_PORT_2,
HAL_UART_PORT_3,
HAL_UART_PORT_4,
HAL_UART_PORT_5,
HAL_UART_PORT_6,
} hal_uart_port_t;
typedef struct hal_uart_st {
hal_uart_port_t port;
void *private_uart;
} hal_uart_t;
__API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port);
__API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout);
__API__ int tos_hal_uart_read(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout);
__API__ int tos_hal_uart_deinit(hal_uart_t *uart);
#endif