xd_protocol.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef _H_XD_PROTOCOL
  2. #define _H_XD_PROTOCOL
  3. //Never change any sequence of following data variables
  4. #pragma pack(1)
  5. typedef struct XD_Status2 {
  6. unsigned char Pass_Fail:1;
  7. unsigned char Dist0_P_F:1;
  8. unsigned char Dist1_P_F:1;
  9. unsigned char Dist2_P_F:1;
  10. unsigned char Dist3_P_F:1;
  11. unsigned char NotUsed:1;
  12. unsigned char Ready_Busy:1;
  13. unsigned char Write_Protect:1;
  14. } XD_Status2_t;
  15. typedef struct XD_ID_91 {
  16. unsigned char Characteristics_Code;
  17. unsigned char Vendor_Specific1;
  18. unsigned char Size_Code;
  19. unsigned char Vendor_Specific2;
  20. unsigned char Vendor_Specific3;
  21. } XD_ID_91_t;
  22. #define CELL_TYPE_SINGLE_LC 0
  23. #define CELL_TYPE_2xMULTI_LC 1
  24. #define CELL_TYPE_4xMULTI_LC 2
  25. #define CELL_TYPE_8xMULTI_LC 4
  26. #define x4_MULTI_BLOCK_NOT_SUPPORTED 0
  27. #define x4_MULTI_BLOCK_SUPPORTED 2
  28. typedef struct _Characteristics_Code {
  29. unsigned char Vendor_Specific1:2;
  30. unsigned char Cell_Type:2;
  31. unsigned char x4_Multi_Block_Flag:2;
  32. unsigned char Vendor_Specific2:2;
  33. } Characteristics_Code_t;
  34. typedef struct XD_ID_9A {
  35. unsigned char Vendor_Specific1;
  36. unsigned char Vendor_Specific2;
  37. unsigned char XD_CARD_ID;
  38. unsigned char Vendor_Specific3;
  39. } XD_ID_9A_t;
  40. #pragma pack()
  41. //Busy Intervals of 16MB to 2 GB XD card
  42. #define XD_BUSY_TIME_PROG (1*TIMER_1MS) //1000us, True Program Busy Time
  43. #define XD_BUSY_TIME_BERASE (10*TIMER_1MS) //10ms, Block Erase Busy Time
  44. #define XD_BUSY_TIME_DBSY (1*TIMER_10US) //10us, Dummy Program Busy Time during Multi Block Programming
  45. #define XD_BUSY_TIME_MBPBSY (1*TIMER_1MS) //1000us, Multi Block Program Busy Time
  46. #define XD_BUSY_TIME_R (3*TIMER_10US) //25us, Data Transfer Time(Cell to Register), 25us
  47. #define XD_BUSY_TIME_RST_PROGRAM (2*TIMER_10US) //20us, Device Resetting Time: Program
  48. #define XD_BUSY_TIME_RST_ERASE (50*TIMER_10US) //0.5ms, Device Resetting Time: Erase
  49. #define XD_BUSY_TIME_RST_READ (1*TIMER_10US) //6us, Device Resetting Time: Read, 6us
  50. #define XD_BUSY_TIME_RST XD_BUSY_TIME_RST_ERASE
  51. #define XD_BUSY_TIME_TCRY (2*TIMER_10US) //6+Tr(RY/-BY)us, -CE High to Ready
  52. #define xd_card_init xd_sm_init
  53. #define xd_read_data xd_sm_read_data
  54. #define xd_write_data xd_sm_write_data
  55. int xd_check_insert(void);
  56. void xd_power_on(void);
  57. void xd_power_off(void);
  58. void xd_prepare_init(void);
  59. void xd_io_config(void);
  60. void enc_trans_end_ctl(void);
  61. void xd_cmd_input_cycle(unsigned char cmd, int enable_write);
  62. void xd_addr_input_cycle(unsigned long addr, int cycles);
  63. void xd_data_input_cycle(unsigned char *data_buf, unsigned long data_cnt,
  64. unsigned char *redundant_buf,
  65. unsigned long redundant_cnt);
  66. void xd_serial_read_cycle(unsigned char *data_buf, unsigned long data_cnt,
  67. unsigned char *redundant_buf,
  68. unsigned long redundant_cnt);
  69. int xd_test_ready(void);
  70. int xd_card_capacity_determin(unsigned char device_code);
  71. //Read data from XD/SM card
  72. int xd_sm_read_data(unsigned long lba, unsigned long byte_cnt,
  73. unsigned char *data_buf);
  74. //Write data to XD/SM card
  75. int xd_sm_write_data(unsigned long lba, unsigned long byte_cnt,
  76. unsigned char *data_buf);
  77. #endif //_H_XD_PROTOCOL