mirror of
https://github.com/sipeed/Maixduino.git
synced 2026-03-03 09:04:00 +01:00
Fix sdcard bug #26
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
#define USE_SPI_LIB
|
||||
#include <Arduino.h>
|
||||
#include "Sd2Card.h"
|
||||
#include "fpioa.h"
|
||||
#include "gpio.h"
|
||||
#include "wiring_digital.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SOFTWARE_SPI
|
||||
#ifdef USE_SPI_LIB
|
||||
@@ -249,8 +252,18 @@ uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
||||
uint32_t arg;
|
||||
|
||||
// set pin modes
|
||||
pinMode(chipSelectPin_, OUTPUT);
|
||||
digitalWrite(chipSelectPin_, HIGH);
|
||||
//#ifdef BOARD_SIPEED_MAIXDUINO
|
||||
int gpionum = get_gpio(chipSelectPin_);
|
||||
if(gpionum >= 0){
|
||||
fpioa_function_t function = fpioa_function_t(FUNC_GPIOHS0 + gpionum);
|
||||
fpioa_set_function(chipSelectPin_, function);
|
||||
gpiohs_set_drive_mode((uint8_t)gpionum, GPIO_DM_OUTPUT);
|
||||
gpiohs_set_pin((uint8_t)gpionum, GPIO_PV_HIGH);
|
||||
}
|
||||
//#else
|
||||
// pinMode(chipSelectPin_, OUTPUT);
|
||||
// digitalWrite(chipSelectPin_, HIGH);
|
||||
//#endif
|
||||
#ifndef USE_SPI_LIB
|
||||
pinMode(SPI_MISO_PIN, INPUT);
|
||||
pinMode(SPI_MOSI_PIN, OUTPUT);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <Sipeed_OV2640.h>
|
||||
#include <Sipeed_ST7789.h>
|
||||
#include <stdio.h>
|
||||
|
||||
SPIClass spi_(SPI0); // MUST be SPI0 for Maix series on board LCD
|
||||
Sipeed_ST7789 lcd(320, 240, spi_);
|
||||
@@ -10,11 +9,12 @@ Sipeed_OV2640 camera(FRAMESIZE_QVGA, PIXFORMAT_RGB565);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
lcd.begin(15000000, COLOR_RED);
|
||||
if(!camera.begin())
|
||||
printf("camera init fail\n");
|
||||
Serial.printf("camera init fail\n");
|
||||
else
|
||||
printf("camera init success\n");
|
||||
Serial.printf("camera init success\n");
|
||||
camera.run(true);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void loop()
|
||||
{
|
||||
uint8_t*img = camera.snapshot();
|
||||
if(img == nullptr || img==0)
|
||||
printf("snap fail\n");
|
||||
Serial.printf("snap fail\n");
|
||||
else
|
||||
lcd.drawImage(0, 0, camera.width(), camera.height(), (uint16_t*)img);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user