u8 draw_lcd(void) { u8 n; init_lcd_spi(); en_lcd(); if(touch_counter==0){ return 0; } touch_counter--; post_cmd(0x210,touch_xy_buffer[touch_rd_index].x); post_cmd(0x212,touch_xy_buffer[touch_rd_index].y); post_cmd(0x211,touch_xy_buffer[touch_rd_index].x+(DOT_WIDTH-1)); post_cmd(0x213,touch_xy_buffer[touch_rd_index].y+(DOT_WIDTH-1)); if(touch_rd_index < (TOUCH_MAX_CACHE-1)){ touch_rd_index++; }else{ touch_rd_index = 0; } //post_cmd(0x0005,0x0010); en_lcd_index(); post_data(0x202); en_lcd_data(); for(n=0; n< (DOT_WIDTH*DOT_WIDTH); n++) { post_data(COLOR_BLACK); } dis_lcd(); return 1; }
PROCESS_THREAD(can_drv_process, ev, data) { static can_cmd_t * cmd; static uint8_t mob_handle; uint8_t do_create_recv_buf = 0; PROCESS_BEGIN(); for(;;) { // wait on polling or timer event PROCESS_WAIT_EVENT(); // Post event about completed commands and free the mob for(mob_handle = 0; mob_handle < NB_MOB; ++mob_handle) { cmd = can_mob[mob_handle]; do_create_recv_buf = 0; if(cmd != NULL) { if(cmd->status != MOB_PENDING) { if(cmd->status & MOB_TX_COMPLETED) { ftimer_unregister_func(cmd->ftimer_id); can_send_callback(CAN_DRV_RC_NORM, cmd->frame, cmd->context); } else if(cmd->status & MOB_RX_COMPLETED) { can_recv_callback(cmd->frame); do_create_recv_buf = 1; } can_mob[mob_handle] = NULL; free(cmd); CAN_SET_MOB(mob_handle); CAN_MOB_ABORT(); } } if(do_create_recv_buf) { create_recv_buf(); } } // If waiting queue not empty, try to schedule waiting commands while( list_head(can_cmd_list) != 0 ) { if(can_get_mob_free() != NO_MOB) { cmd = list_pop(can_cmd_list); post_cmd(cmd); } else { break; } } } PROCESS_END(); }
int can_send(can_frame_t * can_frame, void * context) { can_cmd_t * cmd; if(can_frame == NULL) return -1; cmd = (can_cmd_t *) malloc(sizeof(can_cmd_t)); if(cmd != NULL) { cmd->frame = can_frame; cmd->context = context; cmd->type = TX; cmd->next = NULL; cmd->status = MOB_DISABLE; post_cmd(cmd); cmd->ftimer_id = ftimer_register_func(send_timeout_handler, cmd, can_send_timeout_ms); } else { return -2; } return 0; }
static int create_recv_buf() { can_cmd_t * cmd; cmd = (can_cmd_t *) malloc(sizeof(can_cmd_t)); if(cmd != NULL) { cmd->frame = (can_frame_t *) malloc(sizeof(can_frame_t)); if(cmd->frame != NULL) { cmd->type = RX; cmd->context = 0; cmd->next = 0; cmd->status = MOB_DISABLE; post_cmd(cmd); } else { free(cmd); return -1; } } else { return -1; } return 0; }
void DisplayChar_Reverse(u8 casc,u8 postion_x,u8 postion_y) { u8 i,j,b; const u8 *p; en_lcd(); post_cmd(0x210,postion_x*8); //x start point post_cmd(0x212,postion_y*16); //y start point post_cmd(0x211,postion_x*8+7); //x end point post_cmd(0x213,postion_y*16+15); //y end point post_cmd(0x200,postion_x*8); post_cmd(0x201,postion_y*16); en_lcd_index(); post_data(0x202); en_lcd_data(); p=ascii; p+=casc*16; for(j=16;j>0;j--) { b=*(p+j-1); for(i=0;i<8;i++) { if(b&0x01) { post_data(COLOR_BLACK); } else { post_data(COLOR_YELLOW); } b=b>>1; } } dis_lcd(); }
void init_lcd(void) { u16 x, y;/* touch_counter = 0; touch_wr_index = 0; touch_rd_index = 0;*/ init_lcd_spi(); en_lcd(); lcd_rst(); post_cmd( 0x000, 0x0001 ); /* oschilliation start */ bcm2835_delay( 10 ); /* Power settings */ post_cmd( 0x100, 0x0000 ); /*power supply setup*/ post_cmd( 0x101, 0x0000 ); post_cmd( 0x102, 0x3110 ); post_cmd( 0x103, 0xe200 ); post_cmd( 0x110, 0x009d ); post_cmd( 0x111, 0x0022 ); post_cmd( 0x100, 0x0120 ); bcm2835_delay( 20 ); post_cmd( 0x100, 0x3120 ); bcm2835_delay( 80 ); /* Display control */ post_cmd( 0x001, 0x0100 ); post_cmd( 0x002, 0x0000 ); post_cmd( 0x003, 0x1230 ); post_cmd( 0x006, 0x0000 ); post_cmd( 0x007, 0x0101 ); post_cmd( 0x008, 0x0808 ); post_cmd( 0x009, 0x0000 ); post_cmd( 0x00b, 0x0000 ); post_cmd( 0x00c, 0x0000 ); post_cmd( 0x00d, 0x0018 ); /* LTPS control settings */ post_cmd( 0x012, 0x0000 ); post_cmd( 0x013, 0x0000 ); post_cmd( 0x018, 0x0000 ); post_cmd( 0x019, 0x0000 ); post_cmd( 0x203, 0x0000 ); post_cmd( 0x204, 0x0000 ); post_cmd( 0x210, 0x0000 ); post_cmd( 0x211, 0x00ef ); post_cmd( 0x212, 0x0000 ); post_cmd( 0x213, 0x013f ); post_cmd( 0x214, 0x0000 ); post_cmd( 0x215, 0x0000 ); post_cmd( 0x216, 0x0000 ); post_cmd( 0x217, 0x0000 ); // Gray scale settings post_cmd( 0x300, 0x5343); post_cmd( 0x301, 0x1021); post_cmd( 0x302, 0x0003); post_cmd( 0x303, 0x0011); post_cmd( 0x304, 0x050a); post_cmd( 0x305, 0x4342); post_cmd( 0x306, 0x1100); post_cmd( 0x307, 0x0003); post_cmd( 0x308, 0x1201); post_cmd( 0x309, 0x050a); /* RAM access settings */ post_cmd( 0x400, 0x4027 ); post_cmd( 0x401, 0x0000 ); post_cmd( 0x402, 0x0000 ); /* First screen drive position (1) */ post_cmd( 0x403, 0x013f ); /* First screen drive position (2) */ post_cmd( 0x404, 0x0000 ); post_cmd( 0x200, 0x0000 ); post_cmd( 0x201, 0x0000 ); post_cmd( 0x100, 0x7120 ); post_cmd( 0x007, 0x0103 ); bcm2835_delay( 10 ); post_cmd( 0x007, 0x0113 ); dis_lcd(); }
void LCD_test(void) { u16 temp,num; u8 n,i; en_lcd(); post_cmd(0x210,0x00); post_cmd(0x212,0x0000); post_cmd(0x211,0xEF); post_cmd(0x213,0x013F); post_cmd(0x200,0x0000); post_cmd(0x201,0x0000); en_lcd_index(); post_data(0x202); en_lcd_data(); for(n=0;n<8;n++) { temp=colorfol[n]; for(num=40*240;num>0;num--) { post_data(temp); } } bcm2835_delay(500); for(n=0;n<1;n++) { post_cmd(0x210,0x00); post_cmd(0x212,0x0000); post_cmd(0x211,0xEF); post_cmd(0x213,0x013F); post_cmd(0x200,0x0000); post_cmd(0x201,0x0000); en_lcd_index(); post_data(0x202); en_lcd_data(); temp=colorfol[n]; for(i=0;i<240;i++) { for(num=0;num<320;num++) { post_data(temp); } } // bcm2835_delay(50); } dis_lcd(); }