|
发表于 2016-6-7 13:40:20
|
显示全部楼层
#define SPICS_GPIO_PIN GPIO_SPI_CS_PIN//(GPIO_DISP_LSCE_PIN)
#define SPISCK_GPIO_PIN GPIO_SPI_SCK_PIN//(GPIO_DISP_LSCK_PIN)
#define SPISDA_GPIO_PIN GPIO_SPI_MOSI_PIN//(GPIO_DISP_LSDA_PIN)
#define SET_SPICS_LOW SET_GPIO_OUT(SPICS_GPIO_PIN, 0)
#define SET_SPICS_HIGH SET_GPIO_OUT(SPICS_GPIO_PIN, 1)
#define SET_SPISCK_LOW SET_GPIO_OUT(SPISCK_GPIO_PIN, 0)
#define SET_SPISCK_HIGH SET_GPIO_OUT(SPISCK_GPIO_PIN, 1)
#define SET_SPISDA_LOW SET_GPIO_OUT(SPISDA_GPIO_PIN, 0)
#define SET_SPISDA_HIGH SET_GPIO_OUT(SPISDA_GPIO_PIN, 1) //mt_set_gpio_out
static void spi_send_data(unsigned char data)
{
unsigned int i;
SET_SPICS_LOW;
UDELAY(1);
SET_SPISCK_LOW;
SET_SPISDA_HIGH;
UDELAY(1);
SET_SPISCK_HIGH;
UDELAY(1);
for (i = 0; i < 8; ++ i)
{
SET_SPISCK_LOW;
if (((data<<i) &0x80) ==0x80) {
SET_SPISDA_HIGH;
} else {
SET_SPISDA_LOW;
}
UDELAY(1);
SET_SPISCK_HIGH;
UDELAY(1);
}
SET_SPISCK_LOW;
SET_SPICS_HIGH;
}
static void spi_send_cmd(unsigned char data)
{
unsigned int i;
SET_SPICS_LOW;
UDELAY(1);
SET_SPISCK_LOW;
SET_SPISDA_LOW;
UDELAY(1);
SET_SPISCK_HIGH;
UDELAY(1);
for (i = 0; i < 8; ++ i)
{
SET_SPISCK_LOW;
if (((data<<i) &0x80) ==0x80) {
SET_SPISDA_HIGH;
} else {
SET_SPISDA_LOW;
}
UDELAY(1);
SET_SPISCK_HIGH;
UDELAY(1);
}
SET_SPISCK_LOW;
SET_SPICS_HIGH;
}
|
|