px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_spi_cfg_template.h
1#ifndef __PX_SPI_CFG_H__
2#define __PX_SPI_CFG_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2014 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_spi_cfg.h : SPI Peripheral Driver configuration
16 Author(s): Pieter Conradie
17 Creation Date: 2014-01-15
18
19============================================================================= */
20
21/**
22 * @addtogroup AVR_SPI
23 *
24 * @{
25 */
26
27/* _____STANDARD INCLUDES____________________________________________________ */
28
29/* _____PROJECT INCLUDES_____________________________________________________ */
30#include "px_defs.h"
31#include "px_board.h"
32
33/* _____DEFINITIONS__________________________________________________________ */
34/// Enable/disable support for SPI0 peripheral
35#define PX_SPI_CFG_SPI0_EN 1
36
37/// Default value for SPI Control Register used in px_spi_open().
38#define PX_SPI_CFG_SPCR \
39 ((0 << SPIE) | (1 << SPE) | (0 << DORD) | (1 << MSTR) | (0 << CPOL) | (0 << CPHA) | (0 << SPR1) | (0 << SPR0))
40
41/// Default value for "Use double clock rate" used in px_spi_open().
42#define PX_SPI_CFG_USE_SPI2X 0
43
44/// Specify default baud rate
45#define PX_SPI_CFG_DEFAULT_BAUD PX_SPI_BAUD_CLK_DIV_2
46
47/// Specify default SPI mode (clock phase and polarity)
48#define PX_SPI_CFG_DEFAULT_MODE PX_SPI_MODE0
49
50/// Specify default SPI data order
51#define PX_SPI_CFG_DEFAULT_DATA_ORDER PX_SPI_DATA_ORDER_MSB
52
53/**
54 * Map PX_SPI_CFG_CS_LO() macro to board_spi_cs_lo() function.
55 *
56 * A manual Chip Select function must be implemented, e.g.
57 *
58 * void board_spi_cs_lo(uint8_t cs_id)
59 * {
60 * switch(cs_id)
61 * {
62 * case BOARD_SPI_CS:
63 * PX_GPIO_PIN_SET_LO(PX_GPIO_SPI_CS);
64 * break;
65 *
66 * default:
67 * break;
68 * }
69 * }
70 */
71#define PX_SPI_CFG_CS_LO(cs_id) px_board_spi_cs_lo(cs_id)
72
73/**
74 * Map PX_SPI_CFG_CS_HI() macro to board_spi_cs_hi() function.
75 *
76 * A manual Chip Select function must be implemented, e.g.
77 *
78 * void board_spi_cs_hi(uint8_t cs_id)
79 * {
80 * switch(cs_id)
81 * {
82 * case BOARD_SPI_CS:
83 * PX_GPIO_OUT_SET_HI(PX_GPIO_SPI_CS);
84 * break;
85 *
86 * default:
87 * break;
88 * }
89 * }
90 *
91 */
92#define PX_SPI_CFG_CS_HI(cs_id) px_board_spi_cs_hi(cs_id)
93
94/// @}
95#endif