VirtualCOM.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef __VIRTUALCOM_H
  2. #define __VIRTUALCOM_H
  3. /***********************************************************************************/
  4. #include "includes.h"
  5. #define COM_TX_PORT GPIOA
  6. #define COM_TX_PIN GPIO_Pin_14
  7. #define COM_DATA_HIGH() GPIO_SetBits(COM_TX_PORT, COM_TX_PIN)
  8. #define COM_DATA_LOW() GPIO_ResetBits(COM_TX_PORT, COM_TX_PIN)
  9. #define COM_RX_PORT GPIOA
  10. #define COM_RX_PIN GPIO_Pin_13
  11. #define COM_RX_STAT GPIO_ReadInputDataBit(COM_RX_PORT, COM_RX_PIN)
  12. enum{
  13. COM_START_BIT, //Æðʼλ
  14. COM_D0_BIT, //bit0
  15. COM_D1_BIT, //bit1
  16. COM_D2_BIT, //bit2
  17. COM_D3_BIT, //bit3
  18. COM_D4_BIT, //bit4
  19. COM_D5_BIT, //bit5
  20. COM_D6_BIT, //bit6
  21. COM_D7_BIT, //bit7
  22. COM_STOP_BIT, //ֹͣλ
  23. };
  24. typedef enum {
  25. BAUDRATE_9600,BAUDRATE_4800,BAUDRATE_2400,BAUDRATE_1200,
  26. }BAUDRATE;
  27. typedef enum {
  28. SYSCLK_FREQ_72M,SYSCLK_FREQ_48M,SYSCLK_FREQ_36M,
  29. }SYSCLK_FREQ;
  30. extern int g_iTIM_DelayUs_ct;
  31. extern unsigned char g_ucRecvStat;
  32. extern unsigned char g_ucRecvData;
  33. extern int g_iCOMRXDelayCt;
  34. void TIM_Delay_us(int timeus);
  35. void VirtualCOM_Init(SYSCLK_FREQ SysclkFreq,BAUDRATE BaudRate);
  36. void VirtualCOM_StringSend(unsigned char *str);
  37. void VirtualCOM_ByteSend(unsigned char val);
  38. void COM_RX_Start_Delay(int ct);
  39. #endif
  40. /***********************************************************************************/