ESP32, SPI, at45dbxx data flash
esp-idf\components\driver\include\driver\spi_master.h
esp-idf\components\driver\include\driver\spi_common.h
esp-idf\components\soc\esp32\include\soc\gpio_struct.h
esp-idf\components\driver\include\driver\gpio.h
0. 참고 사이트
1. 모듈
2. 보드 연결
3.3V 사용

3. 소스 설명
2018/08/15 일자 커밋된 소스를 기반으로 작성되었습니다.
테스트 보드는 esp32_devkitc_v4 입니다.
spi_master 소스에서 사용하는 핀을 사용하면
정상적으로 동작하지 않아 다음과 같이 핀을 변경하였습니다.
확인된 부분은 MOSI로 사용된 23번 pin에서
데이터 출력이 되지 않았습니다.
( 추가적으로 저 핀을 output으로 설정하여 high / low 반복해도 반응 안함 )
기타 CLK 19, CS 22 pin은 동작하였습니다.
구글 검색으로는 I/O로 사용할 수 있는 핀 설정에 문제가 있다고 하는데
datasheet, reference manual 상에서는 문제가 없는 것으로 보여서
추가적으로 확인해 봐야 하겠습니다.
spi_master example pin settting
#define PIN_NUM_MISO 25
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK 19
#define PIN_NUM_CS 22
my test pin setting
#define PIN_NUM_MISO 18
#define PIN_NUM_MOSI 27
#define PIN_NUM_CLK 5
#define PIN_NUM_CS 16
4. 소스
https://github.com/sglee0223/esp32/tree/master/at45dbxx_spi
5. 결과 확인

I (0) cpu_start: App cpu up. I (215) heap_init: Initializing. RAM available for dynamic allocation: I (222) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (228) heap_init: At 3FFB3330 len 0002CCD0 (179 KiB): DRAM I (234) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM I (240) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (247) heap_init: At 400896E8 len 00016918 (90 KiB): IRAM I (253) cpu_start: Pro cpu start user code I (271) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. manufacturer: 1f devid1: 24 devid2: 00 capacity: 04 4MBIT DataFlash status register: 9d at45db_test Start ErasingDataFlash Start ErasingDataFlash End FlashBuffer1Write Start FlashBuffer1Write End FlashBuffer1Read Start FlashBuffer1Read End First: [1234567890UUAA] FlashBuffer1ProgAutoErase Start FlashBuffer1ProgAutoErase End FlashBuffer1Write Start FlashBuffer1Write End PageToBuffer1 Start PageToBuffer1 End FlashBuffer1Read Start FlashBuffer1Read End Second: [1234567890UUAA] at45db_test End |
6. 오류 발생 시
실제로 테스트해 본 결과 데이터 수신이 정상적으로 이루어지지 않는 것으로 확인하였습니다.

I (197) cpu_start: App cpu up. I (216) heap_init: Initializing. RAM available for dynamic allocation: I (223) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (229) heap_init: At 3FFB3330 len 0002CCD0 (179 KiB): DRAM I (235) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM I (241) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (248) heap_init: At 400896E8 len 00016918 (90 KiB): IRAM I (254) cpu_start: Pro cpu start user code I (272) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. E (274) spi_master: spi_bus_add_device(351): When GPIO matrix is used in full-duplex mode at frequency > 26.7MHz, device cannot read correct data. Please note the SPI can only work at divisors of 80MHz, and the driver always tries to find the closest frequency to your configuration. Specify ``SPI_DEVICE_NO_DUMMY`` to ignore this checking. Then you can output data at higher speed, or read data at your own risk. |
아래와 같이 iomux 를 사용해야만 가능하다고 합니다.
그 사용법에 대해서는 공부가 필요해 보입니다.

I (197) cpu_start: App cpu up. I (216) heap_init: Initializing. RAM available for dynamic allocation: I (223) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (229) heap_init: At 3FFB3330 len 0002CCD0 (179 KiB): DRAM I (235) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM I (241) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (248) heap_init: At 400896E8 len 00016918 (90 KiB): IRAM I (254) cpu_start: Pro cpu start user code I (272) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. E (274) spi_master: spi_bus_add_device(343): 80MHz only supported on iomux pins ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x400d227f |