Development environment:
MCU: NXP LPC1788
u-boot: u-boot-2010.03
SPI Flash: AT45DB321D
Since ATMEL's SPI flash has been implemented in u-boot, we don't need to write the driver for AT45DB321D. Now consider the SPI bus (the SPI driver in u-boot is in the driver/spi directory). In the driver/spi directory, you can see the SPI bus implementation of various chips, but lpc1788 does not have it. Don't move. You will see a soft_spi.c. Now you don't need to write the driver for the SPI bus. Just use soft SPI.
Add the following content to the lpc1788 configuration file:
#define CONFIG_CMD_SF //Add cmd_sf.c file compilation to implement the spi flash operation command sf in u-boot
#define CONFIG_SOFT_SPI //Add driver/spi/soft_spi.c file to compile and implement software spi bus
#define CONFIG_SPI_FLASH //Add driver/mtd/spi/spi_flash.c file to compile
#define CONFIG_SPI_FLASH_ATMEL //Add driver/mtd/spi/atmel.c file to compile and implement AT45 driver
#define CONFIG_SF_DEFAULT_MODE SPI_MODE_1
#define SPI_SCL spi_scl
#define SPI_SDA spi_sda
#define SPI_READ spi_read()
void spi_scl(int);
void spi_sda(int);
unsigned char spi_read(void);
#define SPI_DELAY udelay(2)
Add the following to the board/nxp/lpc1788/board.c file:
void spi_scl(int bit)
{
struct lpc178x_gpio_dsc dsc;
dsc.port = 2;
dsc.pin = 22;
lpc178x_gpout_set(&dsc, bit);
}
void spi_sda(int bit)
{
struct lpc178x_gpio_dsc dsc;
dsc.port = 2;
dsc.pin = 27;
lpc178x_gpout_set(&dsc, bit);
}
unsigned char spi_read(void)
{
struct lpc178x_gpio_dsc dsc;
dsc.port = 2;
dsc.pin = 26;
return (unsigned char)lpc178x_gpin_get(&dsc);
}
int spi_cs_is_valid(unsigned int bus, unsigned int cs)
{
return bus == 0 && cs == 0;
SPI flash operation commands in u-boot:
1. Select SPI flash
SF probe 0
2. Erase command
SF erase 0 0x210 //Note that the erase length must be an integer multiple of 0x210
3. Read command
SF read addr offset len
4. Write command
SF write addr offset len
Previous article:MicroPython LPC1788 porting
Next article:S3C2440 startup code analysis start.s
Recommended ReadingLatest update time:2024-11-24 10:20
Recommended posts
- Polar Fox received an investment of 100 billion!
- Thisamountofmoney,Ireallywipedmyeyesthreetimes!!! IsaidIdon’tknowhowtoexpressitfornow,let’sjustwatchthenewstogether Recently,ZhangJianyong,chairmanofBAICGroup,saidatthedeliveryceremonyofthefirstbatch
- okhxyyo Automotive Electronics
- "Large Language Model: Principles and Engineering Practice" - Evaluation + Application + Engineering Practice
- #1.EvaluationoflargelanguagemodelsMainevaluationdimensions:1.Languagemodelcapability2.Comprehensiveknowledgecapability1.Commonsensereasoning,suchasPIAQ,SIQA,ARC,etc.2.Readingcomprehension,suchasNaturalQuestions,Triv
- rtyu789 Embedded System
- What are the requirements for lightning protection filter circuit boards for frequency converters?
- SmallpowerinvertersusuallyhaveavaristororvaristorconnectedtothegroundPEontheinputside.Thefunctionofthiscircuitistoshort-circuittheinvertertothegroundtodischargeenergywhenhighvoltagelightningisconnected. Inhi
- 乱世煮酒论天下 Motor Drive Control(Motor Control)
- The application principle and connection method of AND gate circuit
- IntroductiontoANDGateCircuits Fromsmallelectronicwatchestocomplexelectroniccomputers,manyoftheircomponentsaremadeintointegratedcircuits,thatis,dozens,hundreds,oreventensofthousandsofelectroniccomponentsaremadeon
- fish001 Analogue and Mixed Signal
- 【micropython】Bluetooth BLE routine
- TheofficialBLEexampleisout https://github.com/micropython/micropython/tree/master/examples/bluetooth TemperatureSensor #Thisexampledemonstratesasimpletemperaturesensorperipheral. # #Thesensor'slocalvalueupdateseverysec
- dcexpert MicroPython Open Source section
- Please help explain the antenna's directivity diagram. Thank you
- 1.Pleaseexplainthispictureindetail. 2.Whatdoesthehorizontallinefrom18.3ontheleftto18.3ontherightmean? 3.Whydoesthedecibelvaluechangefrom18.3to0.3andthento-5.7fromtheoutsidetotheinside?Shouldn'tthedeci
- 一沙一世 MCU
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- 2015, 2017 real exam questions series!
- Advantages and Challenges of Single-Chip Mobile Phones
- How to create multiple C files in KEIL and what to pay attention to in modular programming
- Domestic Cortex-M0 microcontroller HR8P506, used for small appliances, toy models, fast charging power supplies, alarms, etc.
- Can wireless control modules from different manufacturers be used interchangeably?
- How wireless routers, mesh networks, and Wi-Fi 6 fit together
- Digital Signal Processing: Principles, Algorithms, and Applications (Fourth Edition)
- Why can't keil5 set the keyword tag of the code?
- UCOS porting procedure in small mode
- Chinese version: Configuring FPGA via PCI-E