- Timestamp:
- Sep 14, 2020, 6:36:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_riscv/trunk/asp_baseplatform/gdic/sipeed_st7789/sipeed_st7789.c
r453 r458 83 83 static void set_dcx_control(LCD_Handler_t *hlcd) 84 84 { 85 85 gpio_set_pin(TADR_GPIO_BASE, hlcd->dcx_no, PORT_LOW); 86 86 } 87 87 88 88 static void set_dcx_data(LCD_Handler_t *hlcd) 89 89 { 90 90 gpio_set_pin(TADR_GPIO_BASE, hlcd->dcx_no, PORT_HIGH); 91 91 } 92 92 … … 101 101 102 102 aTxBuffer[0] = c; 103 103 set_dcx_control(hlcd); 104 104 hspi->Init.DataSize = 8; 105 105 hspi->Init.InstLength = 8; 106 106 hspi->Init.AddrLength = 0; 107 107 ercd = spi_core_transmit(hspi, hlcd->cs_sel, (uint8_t *)(aTxBuffer), 1); 108 108 #if SPI_WAIT_TIME == 0 109 109 if(ercd == E_OK) … … 128 128 aTxBuffer[i] = buf[i]; 129 129 130 130 set_dcx_data(hlcd); 131 131 hspi->Init.DataSize = 8; 132 132 hspi->Init.InstLength = 8; … … 146 146 ER ercd = E_OK; 147 147 148 148 set_dcx_data(hlcd); 149 149 hspi->Init.DataSize = 8; 150 150 hspi->Init.InstLength = 8; … … 167 167 ER ercd = E_OK; 168 168 169 169 set_dcx_data(hlcd); 170 170 hspi->Init.DataSize = 16; 171 171 hspi->Init.InstLength = 16; … … 188 188 ER ercd = E_OK; 189 189 190 190 set_dcx_data(hlcd); 191 191 hspi->Init.DataSize = 32; 192 192 hspi->Init.InstLength = 0; … … 206 206 { 207 207 GPIO_Init_t init = {0}; 208 uint8_t data = 0;208 uint8_t data[2] = {0}; 209 209 210 210 /* … … 214 214 init.mode = GPIO_MODE_OUTPUT; 215 215 init.pull = GPIO_PULLDOWN; 216 217 216 gpio_setup(TADR_GPIO_BASE, &init, hlcd->dcx_no); 217 gpio_set_pin(TADR_GPIO_BASE, hlcd->dcx_no, PORT_HIGH); 218 218 219 219 /* … … 227 227 gpio_set_pin(TADR_GPIO_BASE, hlcd->rst_no, PORT_HIGH); 228 228 229 230 229 gpio_set_pin(TADR_GPIO_BASE, hlcd->rst_no, 0); 230 gpio_set_pin(TADR_GPIO_BASE, hlcd->rst_no, 1); 231 231 } 232 232 … … 245 245 */ 246 246 lcd_writecommand(hlcd, PIXEL_FORMAT_SET); 247 data = 0x55;248 247 data[0] = 0x55; 248 lcd_writebyte(hlcd, &data, 1); 249 249 if(hlcd->dir & DIR_XY_MASK){ 250 250 hlcd->_width = ST7789_TFTHEIGHT; … … 259 259 260 260 lcd_writecommand(hlcd, MEMORY_ACCESS_CTL); 261 lcd_writebyte(hlcd, (uint8_t *)&hlcd->dir, 1); 261 lcd_writebyte(hlcd, (uint8_t *)&hlcd->dir, 1); 262 263 //lcd_writecommand(hlcd, RGB_IF_SIGNAL_CTL); 264 //data[0] = 0x00; 265 //data[1] = 0xF8; 266 //lcd_writebyte(hlcd, &data, 2); 262 267 263 268 /* … … 274 279 lcd_setAddrWindow(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) 275 280 { 276 277 278 279 280 281 281 uint8_t data[4] = {0}; 282 283 data[0] = (uint8_t)(x0 >> 8); 284 data[1] = (uint8_t)(x0); 285 data[2] = (uint8_t)(x1 >> 8); 286 data[3] = (uint8_t)(x1); 282 287 lcd_writecommand(hlcd, HORIZONTAL_ADDRESS_SET); 283 284 285 286 287 288 288 lcd_writebyte(hlcd, data, 4); 289 290 data[0] = (uint8_t)(y0 >> 8); 291 data[1] = (uint8_t)(y0); 292 data[2] = (uint8_t)(y1 >> 8); 293 data[3] = (uint8_t)(y1); 289 294 lcd_writecommand(hlcd, VERTICAL_ADDRESS_SET); 290 295 lcd_writebyte(hlcd, data, 4); 291 296 292 297 SVC_PERROR(lcd_writecommand(hlcd, MEMORY_WRITE)); … … 305 310 lcd_fillRect(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, int16_t h, color_t color) 306 311 { 307 312 uint32_t data = ((uint32_t)color << 16) | (uint32_t)color; 308 313 // rudimentary clipping (drawChar w/big text requires this) 309 314 if((x >= hlcd->_width) || (y >= hlcd->_height)) return; … … 312 317 313 318 lcd_setAddrWindow(hlcd, x, y, x+w-1, y+h-1); 314 319 SVC_PERROR(lcd_filldata(hlcd, &data, (h*w+1)/2)); 315 320 } 316 321 … … 326 331 { 327 332 uint32_t data = color; 328 333 lcd_setAddrWindow(hlcd, x, y, x, y); 329 334 SVC_PERROR(lcd_writehalf(hlcd, &data, 1)); 330 335 } … … 341 346 lcd_drawFastVLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t h, color_t color) 342 347 { 343 348 uint32_t data = ((uint32_t)color << 16) | (uint32_t)color; 344 349 // Rudimentary clipping 345 350 if(h == 0) return; … … 347 352 if((y+h-1) >= hlcd->_height) h = hlcd->_height-y; 348 353 lcd_setAddrWindow(hlcd, x, y, x, y+h-1); 349 354 SVC_PERROR(lcd_filldata(hlcd, &data, (h+1)/2)); 350 355 } 351 356 … … 360 365 void lcd_drawFastHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, color_t color) 361 366 { 362 367 uint32_t data = ((uint32_t)color << 16) | (uint32_t)color; 363 368 // Rudimentary clipping 364 369 if(w == 0) return; … … 366 371 if((x+w-1) >= hlcd->_width) w = hlcd->_width-x; 367 372 lcd_setAddrWindow(hlcd, x, y, x+w-1, y); 368 373 SVC_PERROR(lcd_filldata(hlcd, &data, (w+1)/2)); 369 374 } 370 375 … … 462 467 463 468 lcd_setAddrWindow(hlcd, x, y, x+width-1, y+height-1); 464 469 set_dcx_data(hlcd); 465 470 hspi->Init.DataSize = 32; 466 471 hspi->Init.InstLength = 0; … … 533 538 { 534 539 LCD_Handler_t *hlcd = pDrawProp->hlcd; 535 540 int32_t decision; /* Decision Variable */ 536 541 uint32_t current_x; /* Current X Value */ 537 542 uint32_t current_y; /* Current Y Value */
Note:
See TracChangeset
for help on using the changeset viewer.