-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathvariant_CH32V003F4.h
143 lines (118 loc) · 4 KB
/
variant_CH32V003F4.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
*******************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* All rights reserved.
*
* This software component is licensed by WCH under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#pragma once
/* ENABLE Peripherals */
#define ADC_MODULE_ENABLED
#define UART_MODULE_ENABLED
#define SPI_MODULE_ENABLED
#define I2C_MODULE_ENABLED
#define TIM_MODULE_ENABLED
/* CH32V003F4 Pins */
#define PA1 PIN_A1
#define PA2 PIN_A0
#define PC0 2
#define PC1 3
#define PC2 4
#define PC3 5
#define PC4 PIN_A2
#define PC5 7
#define PC6 8
#define PC7 9
#define PD0 10
#define PD1 11
#define PD2 PIN_A3
#define PD3 PIN_A4
#define PD4 PIN_A7
#define PD5 PIN_A5
#define PD6 PIN_A6
#define PD7 17
// Alternate pins number
#define PD5_ALT1 (PD5 | ALT1)
#define PD6_ALT1 (PD6 | ALT1)
#define NUM_DIGITAL_PINS 18
#define NUM_ANALOG_INPUTS 8
// #define ADC_CTLR_ADCAL
#define ADC_RESOLUTION 10
// On-board LED pin number
#ifndef LED_BUILTIN
#define LED_BUILTIN PNUM_NOT_DEFINED
#endif
// On-board user button
#ifndef USER_BTN
#define USER_BTN PNUM_NOT_DEFINED
#endif
// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 1
#endif
// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PD6
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PD5
#endif
// SPI definitions
#ifndef PIN_SPI_SS
#define PIN_SPI_SS PC4
#endif
#ifndef PIN_SPI_MOSI
#define PIN_SPI_MOSI PC6
#endif
#ifndef PIN_SPI_MISO
#define PIN_SPI_MISO PC7
#endif
#ifndef PIN_SPI_SCK
#define PIN_SPI_SCK PC5
#endif
// I2C definitions
#ifndef PIN_WIRE_SDA
#define PIN_WIRE_SDA PC1
#endif
#ifndef PIN_WIRE_SCL
#define PIN_WIRE_SCL PC2
#endif
// Timer Definitions
#ifndef TIMER_TONE
#define TIMER_TONE TIM2
#endif
#ifndef TIMER_SERVO
#define TIMER_SERVO TIM1
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
#ifndef SERIAL_PORT_HARDWARE
#define SERIAL_PORT_HARDWARE Serial
#endif
#endif