Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sst25vfxxxx.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
27#ifndef SST25VFXXXX_H
28#define SST25VFXXXX_H
29
30#include "mcu_periph/spi.h"
31
32/* Register defines */
33#define SST25VFXXXX_READ 0x03
34#define SST25VFXXXX_HGIH_SPEAD_READ 0x0B
35#define SST25VFXXXX_ERASE_4K 0x20
36#define SST25VFXXXX_ERASE_32K 0x52
37#define SST25VFXXXX_ERASE_64K 0xD8
38#define SST25VFXXXX_ERASE_CHIP 0x60
39#define SST25VFXXXX_BYTE_PROG 0x02
40#define SST25VFXXXX_AAI_PROG 0xAD
41#define SST25VFXXXX_RDSR 0x05
42#define SST25VFXXXX_EWSR 0x50
43#define SST25VFXXXX_WRSR 0x01
44#define SST25VFXXXX_WREN 0x06
45#define SST25VFXXXX_WRDI 0x04
46#define SST25VFXXXX_RDID 0x90
47#define SST25VFXXXX_JEDEC_ID 0x9F
48#define SST25VFXXXX_EBSY 0x70
49#define SST25VFXXXX_DBSY 0x80
50
51/* The different statuses the SST25VFxxxx chip can be in */
61
62/* The structure for the SST25VFxxxx chip that handles all the buffers and requests */
76
77void sst25vfxxxx_init(struct SST25VFxxxx *sst, struct spi_periph *spi_p, const uint8_t slave_idx, SPICallback spi_cb);
78void sst25vfxxxx_after_cb(struct SST25VFxxxx *sst);
79void sst25vfxxxx_read_id(struct SST25VFxxxx *sst);
81void sst25vfxxxx_chip_erase(struct SST25VFxxxx *sst);
82void sst25vfxxxx_write(struct SST25VFxxxx *sst, uint8_t *transfer_buffer, uint8_t transfer_length);
83void sst25vfxxxx_read(struct SST25VFxxxx *sst, uint8_t *transfer_buffer, uint8_t transfer_length);
84
85#endif /* SST25VFXXXX_H */
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition spi.h:153
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
Definition spi.h:136
SPI peripheral structure.
Definition spi.h:174
SPI transaction structure.
Definition spi.h:148
uint16_t foo
Definition main_demo5.c:58
Architecture independent SPI (Serial Peripheral Interface) API.
SST25VFxxxxStatus
Definition sst25vfxxxx.h:52
@ SST25VFXXXX_READ_ID
The chip is busy with getting the chip ID.
Definition sst25vfxxxx.h:55
@ SST25VFXXXX_READ_BYTES
The chip is busy reading bytes.
Definition sst25vfxxxx.h:59
@ SST25VFXXXX_WRITE_BYTES
The chip is busy writing bytes.
Definition sst25vfxxxx.h:58
@ SST25VFXXXX_UNINIT
The chip isn't initialized.
Definition sst25vfxxxx.h:53
@ SST25VFXXXX_CHIP_ERASE
The chip is busy erasing itself.
Definition sst25vfxxxx.h:57
@ SST25VFXXXX_IDLE
The chip is idle and can be used.
Definition sst25vfxxxx.h:54
@ SST25VFXXXX_WRITE_EN
The chip is busy enabeling writing to blocks.
Definition sst25vfxxxx.h:56
uint8_t transfer_idx
The transfer idx is used for counting input/output bytes.
Definition sst25vfxxxx.h:73
void sst25vfxxxx_write(struct SST25VFxxxx *sst, uint8_t *transfer_buffer, uint8_t transfer_length)
Write bytes.
uint32_t flash_addr
The flash address to write at.
Definition sst25vfxxxx.h:70
void sst25vfxxxx_block_write_en(struct SST25VFxxxx *sst)
Enable block writing.
void sst25vfxxxx_read_id(struct SST25VFxxxx *sst)
Read the chip identifier.
uint8_t output_buf[16]
The output buffer for the SPI transaction.
Definition sst25vfxxxx.h:69
void sst25vfxxxx_read(struct SST25VFxxxx *sst, uint8_t *transfer_buffer, uint8_t transfer_length)
Read bytes Need 5 more extra bytes because of SPI overhead.
struct spi_transaction spi_t
The SPI transaction used for the writing and reading of registers.
Definition sst25vfxxxx.h:67
void sst25vfxxxx_init(struct SST25VFxxxx *sst, struct spi_periph *spi_p, const uint8_t slave_idx, SPICallback spi_cb)
Initializing the sst25vfxxxx chip.
Definition sst25vfxxxx.c:34
uint8_t transfer_length
The transfer buffer length.
Definition sst25vfxxxx.h:74
void sst25vfxxxx_chip_erase(struct SST25VFxxxx *sst)
Full chip erase.
uint8_t * transfer_buf
The transfer buffer.
Definition sst25vfxxxx.h:72
uint8_t input_buf[16]
The input buffer for the SPI transaction.
Definition sst25vfxxxx.h:68
uint8_t status_idx
The counter of substatuses.
Definition sst25vfxxxx.h:65
void sst25vfxxxx_after_cb(struct SST25VFxxxx *sst)
Callback of the SPI after going one level higher for gathering the sst pointer.
Definition sst25vfxxxx.c:64
enum SST25VFxxxxStatus status
The status of the SST25VFxxxx flash chip.
Definition sst25vfxxxx.h:64
struct spi_periph * spi_p
The SPI peripheral for the connection.
Definition sst25vfxxxx.h:66
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.