// CryptoMemory I2C Header File // // This library is used in all of the low level hardware interface for I2C communications. // // Revision Date Changes // -------- --------- ----------------------------------------------------------------- // 0.1 26 Oct 04 First Release // Protect Library against multiple inclusion #ifndef CM_I2C_H #define CM_I2C_H //#include "hal_interface_api.h" //#include "com_gpio.h" // ------------------------------------------------------------------------------------------------- // Other includes required by this header file // ------------------------------------------------------------------------------------------------- #include "CM_LIB.h" // //Ô¬¿­À¬»ø³ÌÐò // #define CM_DETECT_PI (*(volatile unsigned char *)(CM_PORT_CFG.ucCardSensePort+IO_PORT_IN)) // #define CM_DETECT_PD (*(volatile unsigned char *)(CM_PORT_CFG.ucCardSensePort+IO_PORT_DIR)) // #define CM_DETECT_PIN (CM_PORT_CFG.ucCardSensePin) // #define CM_DETECT_POL (CM_PORT_CFG.ucCardSensePolarity) // #define CM_DETECT_IN CM_DETECT_PD&=~(1<>CM_DATA_PIN)&1) // #define CM_CLK_PD (*(volatile unsigned char *)(CM_PORT_CFG.ucClockPort+IO_PORT_DIR)) // #define CM_CLK_PO (*(volatile unsigned char *)(CM_PORT_CFG.ucClockPort+IO_PORT_OUT)) // #define CM_CLK_PIN (CM_PORT_CFG.ucClockPin) // #define CM_DATA_PI (*(volatile unsigned char *)(CM_PORT_CFG.ucDataPort+IO_PORT_IN)) // #define CM_DATA_PD (*(volatile unsigned char *)(CM_PORT_CFG.ucDataPort+IO_PORT_DIR)) // #define CM_DATA_PO (*(volatile unsigned char *)(CM_PORT_CFG.ucDataPort+IO_PORT_OUT)) // #define CM_DATA_PIN (CM_PORT_CFG.ucDataPin) // #define rPIOA_OER (*(volatile unsigned *)0x40020000 + 0x14) // #define rPIOA_ODR (*(volatile unsigned *)0x40020000 + 0x10) // #define rPIOA_SODR (*(volatile unsigned *)0x40020000 + 0x18) // #define rPIOA_CODR (*(volatile unsigned *)0x40020000 + 0x1A) // #define rPIOA_PDSR (*(volatile unsigned *)0x40020000 + 0x10) // #define SDA ((rPIOA_PDSR&PIN25)?1:0) // /*================================Àî=====================================*/ // #define IO_PORT_DIR (-1) // #define IO_PORT_OUT (0) #if 0 #define GIO_DIR_INPUT 0x00 #define GIO_DIR_OUTPUT 0x01 #define GPIO_CLK GPIO_PIN_6 #define PORT_CLK GPIOE #define GPIO_DATA GPIO_PIN_5 #define PORT_DATA GPIOE #define CM_CLK_OUT stm32_gpio_direct(PORT_CLK,GPIO_CLK,GIO_DIR_OUTPUT) #define CM_CLK_HI stm32_gpio_write(PORT_CLK,GPIO_CLK,GPIO_PIN_SET) #define CM_CLK_LO stm32_gpio_write(PORT_CLK,GPIO_CLK,GPIO_PIN_RESET) #define CM_DATA_OUT stm32_gpio_direct(PORT_DATA,GPIO_DATA,GIO_DIR_OUTPUT) #define CM_DATA_IN stm32_gpio_direct(PORT_DATA,GPIO_DATA,GIO_DIR_INPUT) #define CM_DATA_HI stm32_gpio_write(PORT_DATA,GPIO_DATA,GPIO_PIN_SET) #define CM_DATA_LO stm32_gpio_write(PORT_DATA,GPIO_DATA,GPIO_PIN_RESET) #define CM_DATA_RD stm32_gpio_read(PORT_DATA,GPIO_DATA) #define CM_START_TRIES 10 //(CM_PORT_CFG.ucStartTries) // ------------------------------------------------------------------------------------------------- // Macros that replace small common function // ------------------------------------------------------------------------------------------------- #define CM_CLOCKHIGH cm_Delay(1);(CM_CLK_HI);cm_Delay(1) #define CM_CLOCKLOW cm_Delay(1);(CM_CLK_LO);cm_Delay(1) #define CM_CLOCKCYCLE cm_Delay(1);(CM_CLK_LO);cm_Delay(2);(CM_CLK_HI);cm_Delay(1) #endif /* #if 0 */ // ------------------------------------------------------------------------------------------------- // Low Level Function Prototypes // ------------------------------------------------------------------------------------------------- // Placeholder function that always returns TRUE uint8_t cm_TRUE(void); void cm_PowerOn(void); void cm_PowerOff(void); // Send Command uint8_t cm_SendCommand(uint8_t * pucCommandBuffer); // Receive Data uint8_t cm_ReceiveData(uint8_t * pucReceiveData, uint8_t ucLength); // Send Data uint8_t cm_SendData(uint8_t * pucSendData, uint8_t ucLength); // Random void cm_RandGen(uint8_t * pucRandomData); // Wait Clock void cm_WaitClock(uint8_t ucLoop); // Send Command Byte uint8_t cm_SendCmdByte(uint8_t ucCommand); // end of multiple inclusion protection #endif