Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
targets/TARGET_STM/TARGET_STM32F0/spi_api.c@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| be_bryan | 0:b74591d5ab33 | 1 | /* mbed Microcontroller Library |
| be_bryan | 0:b74591d5ab33 | 2 | ******************************************************************************* |
| be_bryan | 0:b74591d5ab33 | 3 | * Copyright (c) 2015, STMicroelectronics |
| be_bryan | 0:b74591d5ab33 | 4 | * All rights reserved. |
| be_bryan | 0:b74591d5ab33 | 5 | * |
| be_bryan | 0:b74591d5ab33 | 6 | * Redistribution and use in source and binary forms, with or without |
| be_bryan | 0:b74591d5ab33 | 7 | * modification, are permitted provided that the following conditions are met: |
| be_bryan | 0:b74591d5ab33 | 8 | * |
| be_bryan | 0:b74591d5ab33 | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
| be_bryan | 0:b74591d5ab33 | 10 | * this list of conditions and the following disclaimer. |
| be_bryan | 0:b74591d5ab33 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| be_bryan | 0:b74591d5ab33 | 12 | * this list of conditions and the following disclaimer in the documentation |
| be_bryan | 0:b74591d5ab33 | 13 | * and/or other materials provided with the distribution. |
| be_bryan | 0:b74591d5ab33 | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| be_bryan | 0:b74591d5ab33 | 15 | * may be used to endorse or promote products derived from this software |
| be_bryan | 0:b74591d5ab33 | 16 | * without specific prior written permission. |
| be_bryan | 0:b74591d5ab33 | 17 | * |
| be_bryan | 0:b74591d5ab33 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| be_bryan | 0:b74591d5ab33 | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| be_bryan | 0:b74591d5ab33 | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| be_bryan | 0:b74591d5ab33 | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| be_bryan | 0:b74591d5ab33 | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| be_bryan | 0:b74591d5ab33 | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| be_bryan | 0:b74591d5ab33 | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| be_bryan | 0:b74591d5ab33 | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| be_bryan | 0:b74591d5ab33 | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| be_bryan | 0:b74591d5ab33 | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| be_bryan | 0:b74591d5ab33 | 28 | ******************************************************************************* |
| be_bryan | 0:b74591d5ab33 | 29 | */ |
| be_bryan | 0:b74591d5ab33 | 30 | #include "mbed_assert.h" |
| be_bryan | 0:b74591d5ab33 | 31 | #include "mbed_error.h" |
| be_bryan | 0:b74591d5ab33 | 32 | #include "spi_api.h" |
| be_bryan | 0:b74591d5ab33 | 33 | |
| be_bryan | 0:b74591d5ab33 | 34 | #if DEVICE_SPI |
| be_bryan | 0:b74591d5ab33 | 35 | #include "cmsis.h" |
| be_bryan | 0:b74591d5ab33 | 36 | #include "pinmap.h" |
| be_bryan | 0:b74591d5ab33 | 37 | #include "PeripheralPins.h" |
| be_bryan | 0:b74591d5ab33 | 38 | |
| be_bryan | 0:b74591d5ab33 | 39 | #if DEVICE_SPI_ASYNCH |
| be_bryan | 0:b74591d5ab33 | 40 | #define SPI_S(obj) (( struct spi_s *)(&(obj->spi))) |
| be_bryan | 0:b74591d5ab33 | 41 | #else |
| be_bryan | 0:b74591d5ab33 | 42 | #define SPI_S(obj) (( struct spi_s *)(obj)) |
| be_bryan | 0:b74591d5ab33 | 43 | #endif |
| be_bryan | 0:b74591d5ab33 | 44 | |
| be_bryan | 0:b74591d5ab33 | 45 | /* |
| be_bryan | 0:b74591d5ab33 | 46 | * Only the frequency is managed in the family specific part |
| be_bryan | 0:b74591d5ab33 | 47 | * the rest of SPI management is common to all STM32 families |
| be_bryan | 0:b74591d5ab33 | 48 | */ |
| be_bryan | 0:b74591d5ab33 | 49 | int spi_get_clock_freq(spi_t *obj) { |
| be_bryan | 0:b74591d5ab33 | 50 | /* SPI_1, SPI_2. Source CLK is PCKL1 */ |
| be_bryan | 0:b74591d5ab33 | 51 | return HAL_RCC_GetPCLK1Freq(); |
| be_bryan | 0:b74591d5ab33 | 52 | } |
| be_bryan | 0:b74591d5ab33 | 53 | |
| be_bryan | 0:b74591d5ab33 | 54 | #endif |