void can_read_status(){ // Reset the SPI buffer spi_init_buffer(); // Load and TX command spi_load_byte(c2515Status); spi_load_byte(0x00); spi_exchange(); spi_wait_for_completion(); serial_printf("Status = "); serial_print_hex(spi_get_byte(1)); return; }
static unsigned int lcm_compare_id(void) { unsigned int id1 = 0; unsigned int id2 = 0; unsigned int id = 0; config_gpio(); SET_RESET_PIN(1); MDELAY(20); SET_RESET_PIN(0); MDELAY(150); SET_RESET_PIN(1); MDELAY(50); set_lcm_register(0xF000,0x55); set_lcm_register(0xF001,0xAA); set_lcm_register(0xF002,0x52); set_lcm_register(0xF003,0x08); set_lcm_register(0xF004,0x01); send_ctrl_cmd(0xc500); id1 = spi_get_byte(0xc0); //spi_read_data(); MDELAY(20); send_ctrl_cmd(0xc501); id2 = spi_get_byte(0xc0); //spi_read_data(); id = (id1<<8)|id2; #ifdef BUILD_UBOOT printf("lcd_id1=0x%x,lcd_id2=0x%x,lcd_id=0x%x \r\n",id1,id2,id); #else printk("lcd_id1=0x%x,lcd_id2=0x%x,lcd_id=0x%x \r\n",id1,id2,id); #endif return (NT35510_LCM_ID == id)?1:0; }
//////////////////////////////////////////////////////////// // Read the contents of the register at <address> //////////////////////////////////////////////////////////// char can_read_reg(char address){ spi_init_buffer(); // Read command spi_load_byte(c2515Read); // Register address spi_load_byte(address); // Expect one byte answer spi_load_zeros(0x01); // Start the transfer spi_exchange(); spi_wait_for_completion(); return spi_get_byte(2); }