- 浏览: 274239 次
- 性别:
- 来自: 广州
文章分类
/*---------------------------------------------------------------------------- * RL-ARM - FlashFS *---------------------------------------------------------------------------- * Name: SPI_STM32F103.c * Purpose: Serial Peripheral Interface Driver for ST STM32F103 * Rev.: V4.12 *---------------------------------------------------------------------------- * This code is part of the RealView Run-Time Library. * Copyright (c) 2004-2010 KEIL - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #include <File_Config.h> #include "stm32f10x.h" /* SPI_SR - bit definitions. */ #define RXNE 0x01 #define TXE 0x02 #define BSY 0x80 /*---------------------------------------------------------------------------- * SPI Driver Functions *---------------------------------------------------------------------------- * Required functions for SPI driver module: * - void spi_init () * - void spi_ss (U32 ss) * - U8 spi_send (U8 outb) * - void spi_hi_speed (BOOL on) *---------------------------------------------------------------------------*/ /*--------------------------- spi_init --------------------------------------*/ void spi_init (void) { /* Initialize and enable the SSP Interface module. */ /* SPI1_NSS is GPIO, output set to high. */ GPIOA->BSRR = 0x00000010; /* SPI1_SCK, SPI1_MISO, SPI1_MOSI are SPI pins. */ GPIOA->CRL &= ~0xFFFF0000; GPIOA->CRL |= 0xB8B30000; /* Card Sensor PA.8 input */ /* 1 = NO Card, 0 = Card plugged. */ GPIOA->CRH &= ~0x0000000F; GPIOA->CRH |= 0x00000004; /* Enable SPI in Master Mode, CPOL=0, CPHA=0. */ /* Clock speed = fPCLK1 / 256 = 280 kHz at 72 MHz PCLK1 clk. */ SPI1->CR1 = 0x037C; SPI1->CR2 = 0x0000; } /*--------------------------- spi_hi_speed ----------------------------------*/ void spi_hi_speed (BOOL on) { /* Set a SPI clock to low/high speed for SD/MMC. */ if (on == __TRUE) { /* Max. 25 MBit used for Data Transfer. */ /* Actual setting 18 MBits. */ SPI1->CR1 &= ~0x0030; SPI1->CR1 |= 0x0008; } else { /* Max. 400 kBit used in Card Initialization. */ /* Actual setting 280 kBits. */ SPI1->CR1 |= 0x0038; } } /*--------------------------- spi_ss ----------------------------------------*/ void spi_ss (U32 ss) { /* Enable/Disable SPI Chip Select (drive it high or low). */ GPIOA->BSRR = ss ? 0x00000010 : 0x00100000; } /*--------------------------- spi_send --------------------------------------*/ U8 spi_send (U8 outb) { /* Write and Read a byte on SPI interface. */ /* Wait if TXE cleared, Tx FIFO is full. */ while (!(SPI1->SR & TXE)); SPI1->DR = outb; /* Wait if RNE cleared, Rx FIFO is empty. */ while (!(SPI1->SR & RXNE)); return (SPI1->DR); } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/
- ff.zip (675.7 KB)
- 下载次数: 4
发表评论
-
stm8 stm32 nop
2012-09-21 09:15 1245stm8s103f3 0x8000-0x9FFF: 0x9D ... -
CoreSight Debug and Trace Connectors
2012-09-17 09:18 862CoreSight Debug and Trace Conne ... -
DM9006 linux driver
2012-08-15 13:02 1503DM9006 linux driver http://www ... -
hsb_to_rgb
2012-06-20 16:33 0static void hsb_to_rgb(uint1 ... -
stm32 jpeg
2012-05-08 10:06 0jpeg -
STM32和STM8各系列选型表
2012-04-24 13:40 1117STM32和STM8各系列选型表 -
研华推出基于Freescale i.MX53的ARM核心板
2012-02-10 13:36 1042http://www.eepw.com.cn/article/ ... -
helix
2011-11-25 16:34 0helix -
audio dsp
2011-11-07 16:39 0http://alldsp.com/index.html ... -
stm32 softreset
2011-11-07 10:07 984SCB->AIRCR = 0x05FA0004; -
VS1003B Debug
2011-10-06 08:50 0VS1003B 在SM_SDISHARE模式下不能连续soft ... -
stm32 中断号 for IAR PowerPac
2011-09-20 16:53 195100 DCD __intial_s ... -
hashtable for DM9000A
2011-09-09 10:23 1003unsigned long const Crc32Tab ... -
DM9000A for KEIL RL-NET driver
2011-08-22 09:05 1916DM9000AEP 在KEIL RL-NET下的驱动程序,从u ... -
DM9000
2011-08-02 11:42 0/*========================== ... -
用DAC产生正弦波
2011-06-29 14:34 1467MCU: C8051F330, Fmax: 23KHz ... -
STM32 MP3
2011-06-28 09:15 904http://bbs.21ic.com/viewthread. ... -
stm32 lib
2011-04-16 22:00 1107stm32
相关推荐
MDK环境下STM32的串口打印输出程序模版
STM32F103的mdk514安装包
STM32最新MDK支持包
STM32CubeMX is mandatory for use of CMSIS-Driver and MDK-Middleware. This packs contains a subset of the files from STM32Cube_FW_F3 version 1.9.0 (Drivers, STCube documentation and fonts). Updated ...
STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_MDK开发环境STM32开发工具 KEIL_...
Version: 2.5.0 (2020-03-23) Keil.STM32H7xx_DFP.2.5.0.pack Board Support: Added STM32H7B3I_EVAL board support. ...Added support for the external MMC programming algorithm for the STM32H750B-Disco board.
Added global define USE_HAL_DRIVER to the component ::Device:STM32Cube HAL:Common. Added global define USE_FULL_LL_DRIVER to the component ::Device:STM32Cube LL:Common. Restructured board(32F469...
Added global define USE_FULL_LL_DRIVER to component ::Device:STM32Cube LL:Common. Added debugProbe board description. Device Support: Updated SVD files and documentation. Reworked device RAM size. ...
因为基于cortex系列芯片采用的内核都是相同的,区别主要为核外的片上的差异(片上外设主要有芯片生产商来定)。这些差异却导致软件在同内核,不同外设的芯片上移植困难。为了解决不同芯片厂商生产的cortex微控制器...
Version: 2.15.0 (2020-09-28) Keil.STM32F4xx_DFP.2.15.0.pack Download Updated Pack to STM32Cube_FW_F4 Firmware Package version V1.25.1 using HAL Drivers V1.7.9. STM32CubeMX integration (Version 6.0.1)...
ROS下使用rosserial和STM32(ST库)进行通信,4轮驱动MDK5工程
STM32全系列 Keil MDK pack离线包 注:由于上传大小限制,除了F0和F1的包,其他的提供链接通过百度云下载。 包括以下包,当前最新版本(20200115) Keil.STM32F0xx_DFP.2.0.0.pack Keil.STM32F1xx_DFP.2.3.0....
Added source code for: STM32L476G-Disco QSPI, STM32L4P5G-DK OSPI, STM32L4P5G-DK PSRAM STM32L4R9I-DK PSRAM, STM32L4R9I-DK OSPI1 and STM32L4R9I-EVAL OSPI. Added PSRAM external Loader support for STM32...
Keil Mdk 编译器 添加stm32f030x系列芯片的升级文件。 Keil 中Device中无stm32f030x系列芯片,可用此文件添加 包括stm32f030c4 stm32f030c6 stm32f030f4 stm32f030k6 stm32f030r8
本文主要讲了一下关于MDK软件不能模拟仿真STM32的问题解决方法,希望对你的学习有所帮助。
Version: 1.3.0 (2021-03-24) Keil.STM32G4xx_...Added global define USE_HAL_DRIVER and USE_FULL_LL_DRIVER to the component ::Device:STM32Cube Framework:STM32CubeMX. Added debugProbe to board description.
电子-第三章MDK5软件入门STM32F4开发指南正点原子探索者STM32开发板.pdf,单片机/嵌入式STM32-F3/F4/F7/H7
This DFP works either with STM32CubeMX (STM32CubeMX V6.0.0 and STM32Cube_FW_L1 V1.10.0 or higher) or Standalone (no support for STM32CubeMX). This pack contains only a subset of the files from STM32...
Version: 2.1.0 (2020-07-20) Keil.STM32L0xx_DFP.2.1.0.pack ...Added Event Recorder in USB Device examples (for STM32L073Z-EVAL board). Updated with user code templates from MDK-Middleware v7.11.1.