PS_Fgen_FW
4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
Pins.h
Go to the documentation of this file.
1
7
8
#ifndef PINS_H_
9
#define PINS_H_
10
11
#include <Arduino.h>
12
#include <util/delay.h>
13
#include <avr/io.h>
14
15
#define SET_REG_BIT(x, y) x |= (1 << y);
16
#define CLEAR_REG_BIT(x, y) x &= ~(1 << y);
17
18
// Chip select pin bit positions (They are used for faster access than the arduino digital write methods)
19
#define BIT_POS_TS_CS PORTA3
20
#define BIT_POS_TFT_CS PORTB1
21
#define BIT_POS_IO_EXP_CS PORTB2
22
#define BIT_POS_DDS_CS PORTB3
23
#define BIT_POS_PS_CS PORTB4
24
25
// https://camo.githubusercontent.com/331d26748c79ccaf42bb0837711b14728c82e47e6fd21b2997a1b9c5155cf672/68747470733a2f2f692e696d6775722e636f6d2f7a424e506335622e706e67
26
#define PIN_NUMBER_TFT_A0 0
27
#define PIN_NUMBER_TFT_CS 1
28
#define PIN_NUMBER_IO_EXP_CS 2
29
#define PIN_NUMBER_DDS_CS 3
30
#define PIN_NUMBER_PS_CS 4
31
32
#define PIN_NUMBER_USB_RX 8
33
#define PIN_NUMBER_USB_TX 9
34
#define PIN_NUMBER_ENC_A 10
35
#define PIN_NUMBER_ENC_B 11
36
#define PIN_NUMBER_ENC_PB 12
37
#define PIN_NUMBER_DMM1_NEG 13
38
#define PIN_NUMBER_DMM2_NEG 14
39
#define PIN_NUMBER_IO_EXP_INT 15
40
41
// Caution: The key pin numbers are not used. In the KeyPad.h file the complete port C is used directly.
42
#define PIN_NUMBER_KEY_C1 16
43
#define PIN_NUMBER_KEY_C2 17
44
#define PIN_NUMBER_KEY_C3 18
45
#define PIN_NUMBER_KEY_C4 19
46
#define PIN_NUMBER_KEY_R1 20
47
#define PIN_NUMBER_KEY_R2 21
48
#define PIN_NUMBER_KEY_R3 22
49
#define PIN_NUMBER_KEY_R4 23
50
51
#define PIN_NUMBER_ADC_PS_CUR 24
52
#define PIN_NUMBER_ADC_PS_VOLT 25
53
#define PIN_NUMBER_TOUCH_IRQ 26
54
#define PIN_NUMBER_TOUCH_CS 27
55
#define PIN_NUMBER_ADC_5V 28
56
#define PIN_NUMBER_ADC_3V3 29
57
#define PIN_NUMBER_ADC_DVM1 30
58
#define PIN_NUMBER_ADC_DVM2 31
59
63
void
Pins_Init
();
64
65
68
#define SPI_SELECT_TOUCH CLEAR_REG_BIT(PORTA, BIT_POS_TS_CS)
69
#define SPI_DESELECT_TOUCH SET_REG_BIT(PORTA, BIT_POS_TS_CS)
70
71
#define SPI_SELECT_TFT CLEAR_REG_BIT(PORTB, BIT_POS_TFT_CS)
72
#define SPI_DESELECT_TFT SET_REG_BIT(PORTB, BIT_POS_TFT_CS)
73
74
#define SPI_SELECT_DDS CLEAR_REG_BIT(PORTB, BIT_POS_DDS_CS)
75
#define SPI_DESELECT_DDS SET_REG_BIT(PORTB, BIT_POS_DDS_CS)
76
77
#define SPI_SELECT_PS CLEAR_REG_BIT(PORTB, BIT_POS_PS_CS)
78
#define SPI_DESELECT_PS SET_REG_BIT(PORTB, BIT_POS_PS_CS)
79
80
#define SPI_SELECT_IO_EXP CLEAR_REG_BIT(PORTB, BIT_POS_IO_EXP_CS)
81
#define SPI_DESELECT_IO_EXP SET_REG_BIT(PORTB, BIT_POS_IO_EXP_CS)
82
83
#define BITMASK_CS_PORTA (1 << BIT_POS_TS_CS)
84
#define BITMASK_CS_PORTB (1 << BIT_POS_PS_CS) | (1 << BIT_POS_DDS_CS) | (1 << BIT_POS_IO_EXP_CS) | (1 << BIT_POS_TFT_CS)
85
#define SPI_DESELECT_ALL PORTA |= BITMASK_CS_PORTA; PORTB |= BITMASK_CS_PORTB;
86
87
#endif
/* PINS_H_ */
Pins_Init
void Pins_Init()
Initialize all pins (directions and states).
Definition
Pins.cpp:10
PS_Fgen_FW
Pins
Pins.h
Generated on Mon Jan 20 2025 17:33:36 for PS_Fgen_FW by
1.13.2