px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_board.h
1#ifndef __PX_BOARD_H__
2#define __PX_BOARD_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2013 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_board.h : Piconomix ATmega328P Scorpion Board
16 Author(s): Pieter Conradie
17 Creation Date: 2013-12-10
18
19============================================================================= */
20/**
21 * @ingroup BOARDS_AVR
22 * @defgroup BOARDS_AVR_PICONOMIX_SCORPION px_board.h : Piconomix ATmega328P Scorpion Board
23 *
24 * ![Piconomix ATmega328P Scorpion Board](px_scorpion.jpg)
25 *
26 * File(s):
27 * - boards/avr/px_scorpion/inc/px_board.h
28 * - boards/avr/px_scorpion/inc/px_board_gpio.h
29 * - boards/avr/px_scorpion/src/px_board.c
30 *
31 * @{
32 */
33
34/* _____STANDARD INCLUDES____________________________________________________ */
35
36/* _____PROJECT INCLUDES_____________________________________________________ */
37#include "px_defs.h"
38#include "px_board_gpio.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43/* _____DEFINITIONS__________________________________________________________ */
44/// Board name
45#define PX_BOARD_PX_SCORPION
46
47/// Processor frequency in Hz
48#ifndef F_CPU
49#define F_CPU 7372800ul
50#endif
51
52/// @name ADC Channel mux definitions
53/// @{
54#define ADC0 1
55#define ADC1 0
56#define ADC2 7
57#define ADC3 6
58/// @}
59
60/* _____TYPE DEFINITIONS_____________________________________________________ */
61/// Identify which GPIO pins are used for CS in board_spi_cs_lo() and board_spi_cs_hi()
62typedef enum
63{
65 PX_BOARD_SPI_CS, ///< General CS pin on SPI header
66 PX_BOARD_SPI_CS_DF, ///< Adesto AT45D DataFlash
68
69/* _____GLOBAL VARIABLES_____________________________________________________ */
70
71/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
72/**
73 * Initialise the board hardware.
74 */
75extern void px_board_init(void);
76
77/**
78 * Set specified SPI Chip Select low.
79 *
80 * @param cs_id ID which GPIO pin must be used for Chip Select
81 */
82extern void px_board_spi_cs_lo(uint8_t cs_id);
83
84/**
85 * Set specified SPI Chip Select high.
86 *
87 * @param cs_id ID which GPIO pin must be used for Chip Select
88 */
89extern void px_board_spi_cs_hi(uint8_t cs_id);
90
91/**
92 * Blocking delay for specified number of microseconds.
93 *
94 * @param delay_us Number of microseconds to block
95 */
96extern void px_board_delay_us(uint16_t delay_us);
97
98/**
99 * Blocking delay for specified number of milliseconds.
100 *
101 * @param delay_ms Number of milliseconds to block
102 */
103void px_board_delay_ms(uint16_t delay_ms);
104
105/* _____MACROS_______________________________________________________________ */
106/// Detect if push button is being pressed
107#define PX_PB_IS_PRESSED() PX_GPIO_IN_IS_LO(PX_GPIO_PB)
108
109/// Enable LED
110#define PX_LED_ON() PX_GPIO_OUT_SET_HI(PX_GPIO_LED)
111/// Disable LED
112#define PX_LED_OFF() PX_GPIO_OUT_SET_LO(PX_GPIO_LED)
113/// Toggle LED
114#define PX_LED_TOGGLE() PX_GPIO_OUT_TOGGLE(PX_GPIO_LED)
115
116// Select UART Port 0
117#define PX_UART_SEL_0() PX_GPIO_OUT_SET_HI(PX_GPIO_UART_SEL)
118// Select UART Port 1
119#define PX_UART_SEL_1() PX_GPIO_OUT_SET_LO(PX_GPIO_UART_SEL)
120
121#ifdef __cplusplus
122}
123#endif
124
125/// @}
126#endif
@ PX_BOARD_SPI_CS_NONE
Do not perform a chip select.
Definition: px_board.h:55
@ PX_BOARD_SPI_CS
General CS pin on SPI header.
Definition: px_board.h:65
@ PX_BOARD_SPI_CS_DF
Adesto AT45D DataFlash.
Definition: px_board.h:66
void px_board_delay_us(uint16_t delay_us)
Blocking delay for specified number of microseconds.
Definition: px_board.c:222
void px_board_init(void)
Initialise the board hardware.
Definition: px_board.c:168
px_board_spi_cs_t
Identify which GPIO pins are used for CS in px_board_spi_cs_lo() and px_board_spi_cs_hi()
Definition: px_board.h:54
void px_board_delay_ms(uint16_t delay_ms)
Blocking delay for specified number of milliseconds.
Definition: px_board.c:234
void px_board_spi_cs_hi(uint8_t cs_id)
Set specified SPI Chip Select high.
Definition: px_board.c:192
void px_board_spi_cs_lo(uint8_t cs_id)
Set specified SPI Chip Select low.
Definition: px_board.c:180