/*
 * nck2910_drv.h
 *
 *  Created on: 2020Äê12ÔÂ4ÈÕ
 *      Author: nxa16228
 */

#ifndef PEPS_DRV_NCK2910_SPICOM_H_
#define PEPS_DRV_NCK2910_SPICOM_H_

#include "Mcal.h"
#include "status.h"
#include "Lpspi_Ip.h"

#define LZ_SPI_INST				(&Lpspi_Ip_DeviceAttributes_SPI0_PCS0_NCK2910_Instance_0_BOARD_InitPeripherals)
#define LZ_MAX_BUFFER_LENGTH	128U

#define LZ_SPI_LOG_ENABLE			0
#define ENABLE_NCK2910_IRQ_HANDLE	0

typedef enum
{
    lzWaitDis = 0U, /*!< No checking of INT_N or RDY_N signals. */
    lzWaitRDY,      /*!< Waiting for passive level of RDY_N
                         signal before activation of SPI CS is
                         enabled, INT_N is not checked. */
    lzWaitRDY_INT   /*!< Waiting for passive level of RDY_N
                         signal and active level of INT_N signal
                         before activation of SPI CS is enabled. */
} lz_wait_t;

void emios1_irq_callback(void);
status_t LZ_SetupGPIOs(void);
bool LZ_HasDeviceDataPending(void);
bool LZ_IsDeviceReady(void);
status_t LZ_SpiCom_ReadWriteFrame(const Lpspi_Ip_ExternalDeviceType *pExtSpiDevice, lz_wait_t wait, uint8_t *sendFrame, uint8_t *recvFrame, uint8_t sendLen, uint8_t *pRecvLen);
status_t LZ_SpiCom_Readframe(const Lpspi_Ip_ExternalDeviceType *pExtSpiDevice,	lz_wait_t wait, uint8_t*receiveBuff, uint8_t *framelength);
status_t LZ_SpiCom_WriteFrame(const Lpspi_Ip_ExternalDeviceType *pExtSpiDevice, lz_wait_t wait, uint8_t*sendFrame, uint8_t *recvFrame, uint8_t byteToSend);
status_t LZ_Init(void);

extern uint8_t lzSpiTxBuf[LZ_MAX_BUFFER_LENGTH];
extern uint8_t lzSpiRxBuf[LZ_MAX_BUFFER_LENGTH];
extern uint8_t lzSpiTxLen;
extern uint8_t lzSpiRxLen;
extern uint8_t g_IsLzIntAppear;

#endif /* PEPS_DRV_NCK2910_SPICOM_H_ */
