//-----------------------------------------------------------------------------
// TITLE	:Car Application code
// REVISION	:00.01
// AUTHOR	:Chengfj
// COMPANY	:Radioway Co.,Ltd..
// DATE		:2016/05/23
// CHIP		:RW1600

//--------------Include files Segment-----------------------------------------
#include	<8PE531A.H>
#include    "typesdefine.h"
//#include    "timer.h"

#define TX 1     // TX as 0, compile RX

#define NoKey_Press_Time 15000//9000
#define LED_BLINK_TIMER  500
#define CH_HOP_TIME 2

#define WDT_CNT_INIT 0x3000	


#define IDLE       0
#define Press      1


//----------------------Car-RX-------------------------
#define DIR_CTR_L	 PORTAbits.IOA3
#define DIR_CTR_R	 PORTBbits.IOB1
#define DIR_CTR_F    PORTAbits.IOA1
#define DIR_CTR_B    PORTAbits.IOA2

#define KEY_L	 PORTAbits.IOA3
#define KEY_R	 PORTBbits.IOB1
#define KEY_F    PORTAbits.IOA1
#define KEY_B    PORTAbits.IOA2

#define TX_RX_dct PORTAbits.IOA0

#define Try_recv_time     200
#define Try_Pairing_Time  200
#define CH_HOLD_TIME  20

#define Recv_OK       1
#define Recv_NG       0

#define Rx_LED     PORTBbits.IOB2
#define RX_LED_OFF 0
#define RX_LED_ON  1

#define Tx_LED     PORTBbits.IOB2
#define TX_LED_OFF 0
#define TX_LED_ON  1

typedef struct
{
	U8 left_turn;
	U8 right_turn;
	U8 forward;
	U8 backword;
	U8 m_state;
}Pkt_Ctr_t;

typedef struct{
	U8 Cmd;
	U8 Data[5];
}Std_Car_t;

typedef enum{
PairingPayload=0x55,
ControlPayload=0xAA
};

extern void rf_send_data_test(void);
extern void rf_recive_data_test(void);


