openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
lpc17_ssp.h
Go to the documentation of this file.
1/*
2 * openMMC --
3 *
4 * Copyright (C) 2015 Henrique Silva <henrique.silva@lnls.br>
5 *
6 * This program 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
27#ifndef LPC17xx_SSP_H_
28#define LPC17xx_SSP_H_
29
30#include "chip_lpc175x_6x.h"
31#include "ssp_17xx_40xx.h"
32#include "FreeRTOS.h"
33#include "task.h"
34
38#define MAX_SSP_INTERFACES 2
39
43#define SSP(n) LPC_SSP##n
44
45#define SSP_SLAVE 0
46#define SSP_MASTER 1
47#define SSP_INTERRUPT 0
48#define SSP_POLLING 1
49
57
61typedef struct ssp_config {
62 LPC_SSP_T * lpc_id;
64 uint32_t ssel_pin;
65 uint8_t polling;
66 uint8_t frame_size;
67 Chip_SSP_DATA_SETUP_T xf_setup;
68 TaskHandle_t caller_task;
70
71void ssp_init( uint8_t id, uint32_t bitrate, uint8_t frame_sz, bool master_mode, bool poll );
72void ssp_ssel_control( uint8_t id, uint8_t state );
73void ssp_write_read( uint8_t id, uint8_t *tx_buf, uint32_t tx_len, uint8_t *rx_buf, uint32_t rx_len, uint32_t timeout );
74
75#define ssp_chip_init(id) Chip_SSP_Init(SSP(id))
76#define ssp_chip_deinit(id) Chip_SSP_DeInit(SSP(id))
77#define ssp_flush_rx(id) Chip_SSP_Int_FlushData(SSP(id))
78#define ssp_set_bitrate(id, bitrate) Chip_SSP_SetBitRate(SSP(id), bitrate)
79#define ssp_write(id, buffer, buffer_len) ssp_write_read(id, buffer, buffer_len, NULL, 0, 0)
80#define ssp_read(id, buffer, buffer_len, timeout) ssp_write_read(id, NULL, 0, buffer, buffer_len, timeout)
81
82#endif
IRQn_Type
Definition LPC176x5x.h:56
void ssp_init(uint8_t id, uint32_t bitrate, uint8_t frame_sz, bool master_mode, bool poll)
Definition lpc17_ssp.c:99
void ssp_ssel_control(uint8_t id, uint8_t state)
Function that controls the Slave Select (SSEL) signal This pin is controlled manually because the int...
Definition lpc17_ssp.c:94
ssel_state
Slave select states.
Definition lpc17_ssp.h:53
@ DEASSERT
Definition lpc17_ssp.h:55
@ ASSERT
Definition lpc17_ssp.h:54
struct ssp_config ssp_config_t
SSP Interface config struct.
void ssp_write_read(uint8_t id, uint8_t *tx_buf, uint32_t tx_len, uint8_t *rx_buf, uint32_t rx_len, uint32_t timeout)
Definition lpc17_ssp.c:124
SSP Interface config struct.
Definition lpc17_ssp.h:61
uint8_t polling
Definition lpc17_ssp.h:65
uint8_t frame_size
Definition lpc17_ssp.h:66
TaskHandle_t caller_task
Definition lpc17_ssp.h:68
LPC_SSP_T * lpc_id
Definition lpc17_ssp.h:62
IRQn_Type irq
Definition lpc17_ssp.h:63
Chip_SSP_DATA_SETUP_T xf_setup
Definition lpc17_ssp.h:67
uint32_t ssel_pin
Definition lpc17_ssp.h:64