// Analog SPI void AspiCmd(u8 Command_Byte) { int i=8; LCD_A0_LOW(); LCD_CLK_HIGH(); LCD_CLK_HIGH(); LCD_NCS_LOW(); while (i--) { LCD_CLK_LOW(); if (Command_Byte&0x80) LCD_MOSI_HIGH(); else LCD_MOSI_LOW(); Command_Byte <<= 1; LCD_CLK_LOW(); \ LCD_CLK_LOW(); \ LCD_CLK_HIGH(); LCD_CLK_HIGH(); } LCD_NCS_HIGH(); LCD_A0_HIGH(); }
void lcd_send_byte(unsigned char byte) { unsigned char i, temp; temp = byte; for(i = 0; i < 8; i++) { LCD_SCK_LOW(); if(temp & 0x80) { LCD_MOSI_HIGH(); } else { LCD_MOSI_LOW(); } LCD_SCK_HIGH(); temp <<= 1; } }
static void Initialize_SPI(void) { // Initialize SPI Interface pins as GPIOs LCD_MOSI_MAKE_OUT(); LCD_SCK_MAKE_OUT(); LCD_SCK_HIGH(); LCD_MOSI_HIGH(); }
/** Transfer data to a slave (MSB first) * * @param sck the pin to use for the SCK output * @param mosi the pin to use for the MOSI output * @param data the data to transfer * @param bits the number of bits to transfer */ void sspiOutMSB(uint8_t data) { uint8_t bit; for(bit = 0x80; bit; bit >>= 1) { // Bring the clock low LCD_SCK_LOW(); // Set data if(data & bit) { LCD_MOSI_HIGH(); } else { LCD_MOSI_LOW(); } // Bring the clock high LCD_SCK_HIGH(); } }
//Anolog spi void AspiData(u8 Para_data) { int i=8; LCD_CLK_HIGH(); LCD_A0_HIGH(); LCD_NCS_LOW(); while (i--) { LCD_CLK_LOW(); if (Para_data&0x80) LCD_MOSI_HIGH(); else LCD_MOSI_LOW(); Para_data <<= 1; __no_operation(); LCD_CLK_HIGH(); __no_operation(); } LCD_NCS_HIGH(); LCD_A0_HIGH(); }
void AspiCmd(uint8_t Command_Byte) { int i=8; LCD_A0_LOW(); LCD_CLK_HIGH(); LCD_NCS_LOW(); while (i--) { LCD_CLK_LOW(); if(Command_Byte&0x80) { LCD_MOSI_HIGH(); } else LCD_MOSI_LOW(); Command_Byte=Command_Byte<<1; LCD_CLK_HIGH(); } LCD_NCS_HIGH(); LCD_A0_HIGH(); }