RTEMS 6.1-rc6
Loading...
Searching...
No Matches
spi-memdrv.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * SPI driver for spi memory devices
5 */
6
7/*
8 * Copyright (c) 2008 embedded brains GmbH & Co. KG
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _LIBCHIP_SPI_MEMDRV_H
33#define _LIBCHIP_SPI_MEMDRV_H
34
35#include <rtems/libi2c.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*=========================================================================*\
42| Function: |
43\*-------------------------------------------------------------------------*/
44rtems_status_code spi_memdrv_write
45(
46/*-------------------------------------------------------------------------*\
47| Purpose: |
48| write a block of data to memory |
49+---------------------------------------------------------------------------+
50| Input Parameters: |
51\*-------------------------------------------------------------------------*/
52 rtems_device_major_number major, /* major device number */
53 rtems_device_major_number minor, /* minor device number */
54 void *arg /* ptr to write argument struct */
55 );
56/*-------------------------------------------------------------------------*\
57| Return Value: |
58| o = ok or error code |
59\*=========================================================================*/
60
61/*=========================================================================*\
62| Function: |
63\*-------------------------------------------------------------------------*/
64rtems_status_code spi_memdrv_read
65(
66/*-------------------------------------------------------------------------*\
67| Purpose: |
68| read a block of data from memory |
69+---------------------------------------------------------------------------+
70| Input Parameters: |
71\*-------------------------------------------------------------------------*/
72 rtems_device_major_number major, /* major device number */
73 rtems_device_major_number minor, /* minor device number */
74 void *arg /* ptr to read argument struct */
75 );
76/*-------------------------------------------------------------------------*\
77| Return Value: |
78| o = ok or error code |
79\*=========================================================================*/
80
81 typedef struct {
82 uint32_t baudrate; /* tfr rate, bits per second */
83 bool erase_before_program;
84 uint32_t empty_state; /* value of erased cells */
85 uint32_t page_size; /* programming page size in byte */
86 uint32_t sector_size; /* erase sector size in byte */
87 uint32_t mem_size; /* total capacity in byte */
89
90 typedef struct {
91 rtems_libi2c_drv_t libi2c_drv_entry; /* general i2c/spi params */
92 spi_memdrv_param_t spi_memdrv_param; /* private parameters */
94
95 extern rtems_driver_address_table spi_memdrv_rw_ops;
96 extern rtems_driver_address_table spi_memdrv_ro_ops;
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* _LIBCHIP_SPI_MEMDRV_H */
uint32_t rtems_device_major_number
This integer type represents the major number of devices.
Definition: io.h:103
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Legacy I2C Library.
This structure contains the device driver entries.
Definition: io.h:140
Definition: libi2c.h:297
Definition: spi-memdrv.h:81
Definition: spi-memdrv.h:90