//将buf中sec_cnt扇区的数据写入硬盘 static void write2sector(struct disk* hd,void* buf,uint8_t sec_cnt){ uint32_t size_in_byte; if(sec_cnt == 0){ //因为sec_cnt是8为变量,由主调函数将其赋值时,若为256则会将最高位的1丢掉变为0 size_in_byte = 256 * 512; }else{ size_in_byte = sec_cnt * 512; } outsw(reg_data(hd->my_channel),buf,size_in_byte / 2); }
void LCD_data(short data) { int i; reg_data(data); gpio_clr( CD ); gpio_clr( CE ); //usleep(1); // ! Important for(i=1;i<1000;i++); gpio_set( CE ); }
void LCD_command(short command) { int i; reg_data(command); gpio_set( CD ); gpio_clr( CE ); //usleep(1); // ! Important for(i=1;i<1000;i++); gpio_set( CE ); }
/* 硬盘读入sec_cnt个扇区的数据到buf */ static void read_from_sector(struct disk* hd, void* buf, uint8_t sec_cnt) { uint32_t size_in_byte; if (sec_cnt == 0) { /* 因为sec_cnt是8位变量,由主调函数将其赋值时,若为256则会将最高位的1丢掉变为0 */ size_in_byte = 256 * 512; } else { size_in_byte = sec_cnt * 512; } insw(reg_data(hd->my_channel), buf, size_in_byte / 2); }