source: rtems/bsps/arm/atsam/include/bsp/sc16is752.h @ 6fc04f4c

Last change on this file since 6fc04f4c was 6fc04f4c, checked in by Joel Sherrill <joel@…>, on 06/27/22 at 13:46:02

bsps/arm/atsamv: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef LIBBSP_ARM_ATSAM_SC16IS752_H
29#define LIBBSP_ARM_ATSAM_SC16IS752_H
30
31#include <rtems/irq-extension.h>
32#include <libchip/chip.h>
33
34#include <dev/serial/sc16is752.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40/**
41 * @brief The SC16IS752 device context.
42 *
43 * All members are private to the device driver.
44 */
45typedef struct {
46  sc16is752_spi_context base;
47  Pin irq_pin;
48  rtems_interrupt_server_entry irqs_entry;
49  rtems_interrupt_server_action irqs_action;
50  uint32_t irqs_index;
51} atsam_sc16is752_spi_context;
52
53/**
54 * @brief The SC16IS752 device configuration.
55 *
56 * @see atsam_sc16is752_spi_create().
57 */
58typedef struct {
59  /**
60   * @brief The device file path for the new device.
61   */
62  const char *device_path;
63
64  /**
65   * @brief The SC16IS752 mode.
66   */
67  sc16is752_mode mode;
68
69  /**
70   * @brief The input frequency in Hertz of the SC16IS752 chip.  See XTAL1 and
71   * XTAL2 pins.
72   */
73  uint32_t input_frequency;
74
75  /**
76   * @brief The SPI bus device path.
77   */
78  const char *spi_path;
79
80  /**
81   * @brief The SPI chip select (starts with 0, the SPI driver uses
82   * SPI_ChipSelect(1 << spi_chip_select)).
83   */
84  uint8_t spi_chip_select;
85
86  /**
87   * @brief The SPI bus speed in Hertz.
88   */
89  uint32_t spi_speed_hz;
90
91  /**
92   * @brief The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD, PIO_INPUT,
93   * PIO_IT_LOW_LEVEL }.
94   */
95  const Pin irq_pin;
96
97  /**
98   * @brief The index to identify the interrupt server used for interrupt
99   * processing.
100   */
101  uint32_t server_index;
102} atsam_sc16is752_spi_config;
103
104/**
105 * @brief Creates an SPI connected SC16IS752 device.
106 *
107 * This devices uses the interrupt server, see rtems_interrupt_server_create().
108 *
109 * The device claims the interrupt of the PIO block.
110 *
111 * @param[out] ctx is the device context.  It may have an arbitrary content.
112 * @param config is the device configuration.
113 *
114 * @return See sc16is752_spi_create().
115 */
116int atsam_sc16is752_spi_create(
117  atsam_sc16is752_spi_context      *ctx,
118  const atsam_sc16is752_spi_config *config
119);
120
121#ifdef __cplusplus
122}
123#endif /* __cplusplus */
124
125#endif /* LIBBSP_ARM_ATSAM_SC16IS752_H */
Note: See TracBrowser for help on using the repository browser.