2019-08-12 18:06:40 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* boards/arm/kinetis/teensy-3.x/src/k20_spi.c
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2019-08-12 18:06:40 +02:00
|
|
|
****************************************************************************/
|
2015-06-10 01:03:52 +02:00
|
|
|
|
2019-08-12 18:06:40 +02:00
|
|
|
/****************************************************************************
|
2015-06-10 01:03:52 +02:00
|
|
|
* Included Files
|
2019-08-12 18:06:40 +02:00
|
|
|
****************************************************************************/
|
2015-06-10 01:03:52 +02:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/spi/spi.h>
|
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
2020-05-01 03:20:29 +02:00
|
|
|
#include "arm_arch.h"
|
2015-06-10 01:03:52 +02:00
|
|
|
#include "chip.h"
|
2015-12-30 01:07:27 +01:00
|
|
|
#include "kinetis.h"
|
2015-06-10 01:03:52 +02:00
|
|
|
#include "teensy-3x.h"
|
|
|
|
|
2017-02-08 20:33:27 +01:00
|
|
|
#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || \
|
2019-08-12 18:06:40 +02:00
|
|
|
defined(CONFIG_KINETIS_SPI2)
|
2015-06-10 01:03:52 +02:00
|
|
|
|
2019-08-12 18:06:40 +02:00
|
|
|
/****************************************************************************
|
2015-06-10 01:03:52 +02:00
|
|
|
* Public Functions
|
2019-08-12 18:06:40 +02:00
|
|
|
****************************************************************************/
|
2015-06-10 01:03:52 +02:00
|
|
|
|
2019-08-12 18:06:40 +02:00
|
|
|
/****************************************************************************
|
2016-01-26 23:25:44 +01:00
|
|
|
* Name: kinetis_spidev_initialize
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2021-03-18 09:57:48 +01:00
|
|
|
* Called to configure SPI chip select GPIO pins for the KwikStik-K40
|
|
|
|
* board.
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2019-08-12 18:06:40 +02:00
|
|
|
****************************************************************************/
|
2015-06-10 01:03:52 +02:00
|
|
|
|
2016-01-26 23:25:44 +01:00
|
|
|
void weak_function kinetis_spidev_initialize(void)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
|
|
|
# warning "Missing logic"
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:06:40 +02:00
|
|
|
/****************************************************************************
|
2017-02-08 20:33:27 +01:00
|
|
|
* Name: kinetis_spi0/1/2select and kinetis_spi0/1/2status
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2021-03-18 09:57:48 +01:00
|
|
|
* The external functions, kinetis_spi0/1/2select and
|
|
|
|
* kinetis_spi0/1/2status must be provided by board-specific logic.
|
2019-08-12 18:06:40 +02:00
|
|
|
* They are implementations of the select and status methods of the SPI
|
|
|
|
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
|
2021-03-18 09:57:48 +01:00
|
|
|
* All other methods (including kinetis_spibus_initialize()) are provided
|
|
|
|
* by common Kinetis logic.
|
2019-08-12 18:06:40 +02:00
|
|
|
* To use this common SPI logic on your board:
|
2015-06-10 01:03:52 +02:00
|
|
|
*
|
2019-08-12 18:06:40 +02:00
|
|
|
* 1. Provide logic in kinetis_boardinitialize() to configure SPI chip
|
|
|
|
* select pins.
|
|
|
|
* 2. Provide kinetis_spi0/1/2select() and kinetis_spi0/1/2status()
|
|
|
|
* functions in your board-specific logic.
|
|
|
|
* These functions will perform chip selection and status operations
|
|
|
|
* using GPIOs in the way your board is configured.
|
|
|
|
* 3. Add a calls to kinetis_spibus_initialize() in your low level
|
|
|
|
* application initialization logic
|
2021-03-18 09:57:48 +01:00
|
|
|
* 4. The handle returned by kinetis_spibus_initialize() may then be used
|
|
|
|
* to bind the SPI driver to higher level logic (e.g., calling
|
2015-06-10 01:03:52 +02:00
|
|
|
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
|
|
|
* the SPI MMC/SD driver).
|
|
|
|
*
|
2019-08-12 18:06:40 +02:00
|
|
|
****************************************************************************/
|
2015-06-10 01:03:52 +02:00
|
|
|
|
2017-02-08 20:33:27 +01:00
|
|
|
#ifdef CONFIG_KINETIS_SPI0
|
2019-08-12 18:06:40 +02:00
|
|
|
void kinetis_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
|
|
|
|
bool selected)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
2019-08-12 18:06:40 +02:00
|
|
|
spiinfo("devid: %d CS: %s\n", (int)devid,
|
|
|
|
selected ? "assert" : "de-assert");
|
2015-06-10 01:03:52 +02:00
|
|
|
# warning "Missing logic"
|
|
|
|
}
|
|
|
|
|
2017-04-28 18:31:10 +02:00
|
|
|
uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
|
|
|
# warning "Missing logic"
|
|
|
|
return SPI_STATUS_PRESENT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-02-08 20:33:27 +01:00
|
|
|
#ifdef CONFIG_KINETIS_SPI1
|
2019-08-12 18:06:40 +02:00
|
|
|
void kinetis_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
|
|
|
bool selected)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
2019-08-12 18:06:40 +02:00
|
|
|
spiinfo("devid: %d CS: %s\n", (int)devid,
|
|
|
|
selected ? "assert" : "de-assert");
|
2015-06-10 01:03:52 +02:00
|
|
|
# warning "Missing logic"
|
|
|
|
}
|
|
|
|
|
2017-04-28 18:31:10 +02:00
|
|
|
uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
|
|
|
# warning "Missing logic"
|
|
|
|
return SPI_STATUS_PRESENT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-02-08 20:33:27 +01:00
|
|
|
#ifdef CONFIG_KINETIS_SPI2
|
2019-08-12 18:06:40 +02:00
|
|
|
void kinetis_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
|
|
|
|
bool selected)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
2019-08-12 18:06:40 +02:00
|
|
|
spiinfo("devid: %d CS: %s\n", (int)devid,
|
|
|
|
selected ? "assert" : "de-assert");
|
2015-06-10 01:03:52 +02:00
|
|
|
# warning "Missing logic"
|
|
|
|
}
|
|
|
|
|
2017-04-28 18:31:10 +02:00
|
|
|
uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
2015-06-10 01:03:52 +02:00
|
|
|
{
|
|
|
|
# warning "Missing logic"
|
|
|
|
return SPI_STATUS_PRESENT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-02-08 20:33:27 +01:00
|
|
|
#endif /* CONFIG_KINETIS_SPI0 || CONFIG_KINETIS_SPI1 || CONFIG_KINETIS_SPI2 */
|