1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _HARDWARE_PLATFORM_DEFS_H
8 #define _HARDWARE_PLATFORM_DEFS_H
9 
10 // This header is included from C and assembler - intended mostly for #defines; guard other stuff with #ifdef __ASSEMBLER__
11 
12 #ifndef _u
13 #ifdef __ASSEMBLER__
14 #define _u(x) x
15 #else
16 #define _u(x) x ## u
17 #endif
18 #endif
19 
20 #define NUM_CORES _u(2)
21 #define NUM_DMA_CHANNELS _u(12)
22 #define NUM_DMA_TIMERS _u(4)
23 #define NUM_IRQS _u(32)
24 #define NUM_USER_IRQS _u(6)
25 #define NUM_PIOS _u(2)
26 #define NUM_PIO_STATE_MACHINES _u(4)
27 #define NUM_PWM_SLICES _u(8)
28 #define NUM_SPIN_LOCKS _u(32)
29 #define NUM_UARTS _u(2)
30 #define NUM_I2CS _u(2)
31 #define NUM_SPIS _u(2)
32 #define NUM_TIMERS _u(4)
33 #define NUM_ADC_CHANNELS _u(5)
34 
35 #define NUM_BANK0_GPIOS _u(30)
36 #define NUM_QSPI_GPIOS _u(6)
37 
38 #define PIO_INSTRUCTION_COUNT _u(32)
39 
40 // PICO_CONFIG: XOSC_KHZ, The crystal oscillator frequency in kHz, type=int, default=12000, advanced=true, group=hardware_base
41 // NOTE:  The system and USB clocks are generated from the frequency using two PLLs.
42 // If you override this define, or SYS_CLK_KHZ/USB_CLK_KHZ below, you will *also* need to add your own adjusted PLL set-up defines to
43 // override the defaults which live in src/rp2_common/hardware_clocks/include/hardware/clocks.h
44 // Please see the comments there about calculating the new PLL setting values.
45 #ifndef XOSC_KHZ
46 #define XOSC_KHZ _u(12000)
47 #endif
48 
49 // PICO_CONFIG: SYS_CLK_KHZ, The system operating frequency in kHz, type=int, default=125000, advanced=true, group=hardware_base
50 #ifndef SYS_CLK_KHZ
51 #define SYS_CLK_KHZ _u(125000)
52 #endif
53 
54 // PICO_CONFIG: USB_CLK_KHZ, USB clock frequency. Must be 48MHz for the USB interface to operate correctly, type=int, default=48000, advanced=true, group=hardware_base
55 #ifndef USB_CLK_KHZ
56 #define USB_CLK_KHZ _u(48000)
57 #endif
58 
59 // For backwards compatibility define XOSC_MHZ if the frequency is indeed an integer number of Mhz.
60 #if defined(XOSC_KHZ) && !defined(XOSC_MHZ) && (XOSC_KHZ % 1000 == 0)
61 #define XOSC_MHZ (XOSC_KHZ / 1000)
62 #endif
63 
64 // For backwards compatibility define SYS_CLK_MHZ if the frequency is indeed an integer number of Mhz.
65 #if defined(SYS_CLK_KHZ) && !defined(SYS_CLK_MHZ) && (SYS_CLK_KHZ % 1000 == 0)
66 #define SYS_CLK_MHZ (SYS_CLK_KHZ / 1000)
67 #endif
68 
69 // For backwards compatibility define USB_CLK_MHZ if the frequency is indeed an integer number of Mhz.
70 #if defined(USB_CLK_KHZ) && !defined(USB_CLK_MHZ) && (USB_CLK_KHZ % 1000 == 0)
71 #define USB_CLK_MHZ (USB_CLK_KHZ / 1000)
72 #endif
73 
74 #define FIRST_USER_IRQ (NUM_IRQS - NUM_USER_IRQS)
75 #define VTABLE_FIRST_IRQ 16
76 
77 #endif
78 
79