|
3楼
楼主 |
发表于 2010-4-14 13:54:21
|
只看该作者
<font color=red> twi.h <font color=brown>
//! \brief import configurations
#include "app_cfg.h"
#define REQ_FAILED 0xE0
#define REQ_RCV_BUFFER_OVF 0xE1
#define REQ_BUS_ERROR 0xE2
#define REQ_CANCELLED 0xE3
#define REQ_UNKONW_ERROR 0xFF
#define REQ_SUCCESS 0x01
#define REQ_ON_GOING 0x00
typedef void TWI_WRITE_REQ_REPORT(uint8_t chResult);
typedef void TWI_READ_REQ_REPORT(uint8_t chResult, uint8_t *pchStream, uint8_t chLength);
/*! \note twi slave model initializing function
*!
*! \param none
*!
*! \return none
*/
extern void twi_slave_init(void);
#define reset_twi() twi_slave_init()
/*! \note request send stream to master
*!
*! \param pStream a point of stream
*!
*! \param chLength byte count of stream
*!
*! \param fnHandler a callback function pointer
*!
*! \return a boolean value to indicate the resule of accessing
*/
extern bool request_send_stream(volatile void *pStream, uint8_t chLength, TWI_WRITE_REQ_REPORT *fnHandler);
/*! \note try to cancel current sending request
*!
*! \param none
*!
*! \return a boolean value to indicate the resule of accessing
*/
extern bool try_to_cancel_send_request(void);
/*! \note request receive data from master
*!
*! \param pStream a point of stream
*!
*! \param chLength stream buffer size
*!
*! \param fnHandler a callback function pointer
*!
*! \return a boolean value to indicate the resule of accessing
*/
extern bool request_receive_stream(volatile void *pStream, uint8_t chLength, TWI_READ_REQ_REPORT *fnHandler);
/*! \note try to cancel current receive request
*!
*! \param none
*!
*! \return a boolean value to indicate the resule of accessing
*/
extern bool try_to_cancel_receive_request(void);
/*! \note release SCL
*!
*! \param none
*!
*! \return none
*/
extern void release_twi(void);
//! \brief twi task locker
extern ES_LOCKER g_lkTWILocker; |
|