115 lines
4.0 KiB
C
115 lines
4.0 KiB
C
|
/****************************************************************************
|
||
|
|
||
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||
|
|
||
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||
|
be copied by any method or incorporated into another program without
|
||
|
the express written consent of Aerospace C.Power. This Information or any portion
|
||
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||
|
liability for its use in any way and conveys no license or title under
|
||
|
any patent or copyright and makes no representation or warranty that this
|
||
|
Information is free from patent or copyright infringement.
|
||
|
|
||
|
****************************************************************************/
|
||
|
#ifndef __FDMA_MST_PROTOCOL_H__
|
||
|
#define __FDMA_MST_PROTOCOL_H__
|
||
|
|
||
|
#include "os_types.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
// clk cs ms
|
||
|
#define GPIO_S_CLK 9
|
||
|
#define GPIO_S_CS 34
|
||
|
#define GPIO_S_MS 35
|
||
|
|
||
|
#define INVALID_DRIVER 0
|
||
|
|
||
|
#define FMST_CMD_ID_OFFSET 28
|
||
|
#define FMST_CMD_ID_MASK 0xf
|
||
|
#define FMST_CMD_PARAM_OFFSET 0
|
||
|
#define FMST_CMD_PARAM_MASK 0x0fffffff
|
||
|
|
||
|
#define FMST_CMD_NOP 0x0
|
||
|
#define FMST_CMD_INIT 0x1
|
||
|
#define FMST_CMD_READ_ALLOCATE 0x4
|
||
|
#define FMST_CMD_READ_FETCH 0x5
|
||
|
#define FMST_CMD_PING 0x6
|
||
|
#define FMST_CMD_WRITE 0x7
|
||
|
#define FMST_CMD_CPU_RESET 0x8
|
||
|
#define FMST_CMD_CPU_RESET_RELEASE 0x9
|
||
|
#define FMST_CMD_MODULE_STS 0xf
|
||
|
|
||
|
#define RX_BUFF_LENTH 200
|
||
|
|
||
|
#ifndef NTOHL
|
||
|
#define NTOHL(x) \
|
||
|
(((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | \
|
||
|
((x & 0xff000000) >> 24))
|
||
|
#endif
|
||
|
|
||
|
#ifndef NTOHS
|
||
|
#define NTOHS(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
|
||
|
#endif
|
||
|
|
||
|
#define FMST_SET_CMD(cmd, param) \
|
||
|
((((uint32_t)cmd & FMST_CMD_ID_MASK) << FMST_CMD_ID_OFFSET) | \
|
||
|
((uint32_t)param & FMST_CMD_PARAM_MASK) << FMST_CMD_PARAM_OFFSET)
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_write() - write data to address by simu spi
|
||
|
* @param [in] addr: address
|
||
|
* @param [in] w_lenth: lenth of data
|
||
|
* @param [in] w_data: pointer to content of data
|
||
|
*/
|
||
|
void iot_spi_fdma_master_write(uint32_t addr, uint32_t w_lenth,
|
||
|
uint32_t* w_data);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_read() - read data from address by simu spi
|
||
|
* @param [in] addr: address
|
||
|
* @param [in] r_lenth: lenth of data
|
||
|
* @param [out] rx_buff: buff to hold rx data
|
||
|
* @return: error code, see ERR_XXX.
|
||
|
*/
|
||
|
uint16_t iot_spi_fdma_master_read(uint32_t addr, uint32_t r_lenth,
|
||
|
uint32_t* rx_buff);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_get_debuginfo() - get debug infomation by simu spi
|
||
|
* @param [in] id: debug id
|
||
|
* @param [out] rx_buff: buff to hold debug info
|
||
|
* @return: error code, see ERR_XXX.
|
||
|
*/
|
||
|
uint16_t iot_spi_fdma_master_get_debuginfo(uint32_t id, uint32_t* rx_buff);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_reset_cpu() - reset cpu by simu spi
|
||
|
*/
|
||
|
void iot_spi_fdma_master_reset_cpu(void);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_reset_release_cpu() - release cpu by simu spi
|
||
|
*/
|
||
|
void iot_spi_fdma_master_reset_release_cpu(void);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_ping() - ping by simu spi
|
||
|
* @param [out] rx_buff: pointer to rx buff to hold rx data.
|
||
|
* @return:error code, see ERR_XXX.
|
||
|
*/
|
||
|
uint16_t iot_spi_fdma_master_ping(uint32_t* rx_buff);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_spi_fdma_master_nop() - nop by simu spi
|
||
|
*/
|
||
|
void iot_spi_fdma_master_nop(void);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif //__FDMA_MST_PROTOCOL_H__
|