File indexing completed on 2025-05-11 08:23:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef LIBBSP_ARM_LPC176X_IO_DEFS_H
0023 #define LIBBSP_ARM_LPC176X_IO_DEFS_H
0024
0025 #include <bsp/lpc176x.h>
0026 #include <bsp/common-types.h>
0027
0028 #ifdef __cplusplus
0029 extern "C" {
0030 #endif
0031
0032 #define LPC176X_PLL0CON 0XAAU
0033 #define LPC176X_PLL0CFG 0X55U
0034
0035 #define LPC176X_CCLK_PRESCALER_DIVISOR 1000000U
0036
0037 #define LPC176X_PINSEL ( &PINSEL0 )
0038 #define LPC176X_PINMODE ( &PINMODE0 )
0039
0040 #define LPC176X_PIN_SELECT( index ) ( ( index ) >> 4U )
0041 #define LPC176X_PIN_SELECT_SHIFT( index ) ( ( ( index ) & 0xFU ) << 1U )
0042 #define LPC176X_PIN_SELECT_MASK 0x3U
0043 #define LPC176X_PIN_SELECT_MASK_SIZE 2U
0044 #define LPC176X_PIN_UART_0_TXD 2U
0045 #define LPC176X_PIN_UART_0_RXD 3U
0046 #define LPC176X_PIN_UART_1_TXD 15U
0047 #define LPC176X_PIN_UART_1_RXD 16U
0048 #define LPC176X_PIN_UART_2_TXD 10U
0049 #define LPC176X_PIN_UART_2_RXD 11U
0050 #define LPC176X_PIN_UART_3_TXD 0U
0051 #define LPC176X_PIN_UART_3_RXD 1U
0052
0053 #define LPC176X_MODULE_BITS_COUNT 32U
0054 #define LPC176X_MODULE_COUNT ( LPC176X_MODULE_USB + 1U )
0055
0056 #define LPC176X_IO_PORT_COUNT 5U
0057 #define LPC176X_IO_INDEX_MAX ( LPC176X_IO_PORT_COUNT * \
0058 LPC176X_MODULE_BITS_COUNT )
0059 #define LPC176X_IO_INDEX_BY_PORT( port, bit ) ( ( ( port ) << 5U ) + ( bit ) )
0060 #define LPC176X_IO_PORT( index ) ( ( index ) >> 5U )
0061 #define LPC176X_IO_PORT_BIT( index ) ( ( index ) & 0x1FU )
0062
0063
0064
0065
0066
0067
0068 typedef enum {
0069 LPC176X_PIN_FUNCTION_00,
0070 LPC176X_PIN_FUNCTION_01,
0071 LPC176X_PIN_FUNCTION_10,
0072 LPC176X_PIN_FUNCTION_11,
0073 LPC176X_PIN_FUNCTION_COUNT
0074 }
0075 lpc176x_pin_function;
0076
0077
0078
0079
0080
0081 typedef enum {
0082 LPC176X_PIN_MODE_PULLUP,
0083 LPC176X_PIN_MODE_REPEATER,
0084 LPC176X_PIN_MODE_NONE,
0085 LPC176X_PIN_MODE_PULLDOWN,
0086 LPC176X_PIN_MODE_COUNT
0087 }
0088 lpc176x_pin_mode;
0089
0090
0091
0092
0093
0094
0095 typedef enum {
0096 LPC176X_PIN_TYPE_DEFAULT,
0097 LPC176X_PIN_TYPE_ADC,
0098 LPC176X_PIN_TYPE_DAC,
0099 LPC176X_PIN_TYPE_OPEN_DRAIN
0100 } lpc176x_pin_type;
0101
0102
0103
0104
0105
0106
0107 typedef enum {
0108 LPC176X_SCB_PCLKSEL0,
0109 LPC176X_SCB_PCLKSEL1,
0110 LPC176X_SCB_PCLKSEL_COUNT
0111 } lpc176x_scb_value_pclksel;
0112
0113
0114
0115
0116 typedef struct {
0117
0118
0119
0120 unsigned char power : 1;
0121
0122
0123
0124 unsigned char clock : 1;
0125
0126
0127
0128 unsigned char index : 6;
0129 } lpc176x_module_entry;
0130
0131 #define LPC176X_MODULE_ENTRY( mod, pwr, clk, idx ) \
0132 [ mod ] = { \
0133 .power = pwr, \
0134 .clock = clk, \
0135 .index = idx \
0136 }
0137
0138 #ifdef __cplusplus
0139 }
0140 #endif
0141
0142 #endif