Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /* mbed Microcontroller Library
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2015-2016 Nuvoton
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
sahilmgandhi 18:6a4db94011d3 5 * you may not use this file except in compliance with the License.
sahilmgandhi 18:6a4db94011d3 6 * You may obtain a copy of the License at
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * http://www.apache.org/licenses/LICENSE-2.0
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * Unless required by applicable law or agreed to in writing, software
sahilmgandhi 18:6a4db94011d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
sahilmgandhi 18:6a4db94011d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sahilmgandhi 18:6a4db94011d3 13 * See the License for the specific language governing permissions and
sahilmgandhi 18:6a4db94011d3 14 * limitations under the License.
sahilmgandhi 18:6a4db94011d3 15 */
sahilmgandhi 18:6a4db94011d3 16 #ifndef MBED_PINNAMES_H
sahilmgandhi 18:6a4db94011d3 17 #define MBED_PINNAMES_H
sahilmgandhi 18:6a4db94011d3 18
sahilmgandhi 18:6a4db94011d3 19 #include "cmsis.h"
sahilmgandhi 18:6a4db94011d3 20
sahilmgandhi 18:6a4db94011d3 21 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 22 extern "C" {
sahilmgandhi 18:6a4db94011d3 23 #endif
sahilmgandhi 18:6a4db94011d3 24
sahilmgandhi 18:6a4db94011d3 25 #define NU_PININDEX_Pos 0
sahilmgandhi 18:6a4db94011d3 26 #define NU_PININDEX_Msk (0xFFul << NU_PININDEX_Pos)
sahilmgandhi 18:6a4db94011d3 27 #define NU_PINPORT_Pos 8
sahilmgandhi 18:6a4db94011d3 28 #define NU_PINPORT_Msk (0xFul << NU_PINPORT_Pos)
sahilmgandhi 18:6a4db94011d3 29 #define NU_PIN_MODINDEX_Pos 12
sahilmgandhi 18:6a4db94011d3 30 #define NU_PIN_MODINDEX_Msk (0xFul << NU_PIN_MODINDEX_Pos)
sahilmgandhi 18:6a4db94011d3 31 #define NU_PIN_BIND_Pos 16
sahilmgandhi 18:6a4db94011d3 32 #define NU_PIN_BIND_Msk (0x1ul << NU_PIN_BIND_Pos)
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34 #define NU_PININDEX(PINNAME) (((unsigned int)(PINNAME) & NU_PININDEX_Msk) >> NU_PININDEX_Pos)
sahilmgandhi 18:6a4db94011d3 35 #define NU_PINPORT(PINNAME) (((unsigned int)(PINNAME) & NU_PINPORT_Msk) >> NU_PINPORT_Pos)
sahilmgandhi 18:6a4db94011d3 36 #define NU_PIN_BIND(PINNAME) (((unsigned int)(PINNAME) & NU_PIN_BIND_Msk) >> NU_PIN_BIND_Pos)
sahilmgandhi 18:6a4db94011d3 37 #define NU_PIN_MODINDEX(PINNAME) (((unsigned int)(PINNAME) & NU_PIN_MODINDEX_Msk) >> NU_PIN_MODINDEX_Pos)
sahilmgandhi 18:6a4db94011d3 38 #define NU_PINNAME(PORT, PIN) ((((unsigned int) (PORT)) << (NU_PINPORT_Pos)) | (((unsigned int) (PIN)) << NU_PININDEX_Pos))
sahilmgandhi 18:6a4db94011d3 39 #define NU_PINNAME_BIND(PINNAME, modname) NU_PINNAME_BIND_(NU_PINPORT(PINNAME), NU_PININDEX(PINNAME), modname)
sahilmgandhi 18:6a4db94011d3 40 #define NU_PINNAME_BIND_(PORT, PIN, modname) ((((unsigned int)(PORT)) << NU_PINPORT_Pos) | (((unsigned int)(PIN)) << NU_PININDEX_Pos) | (NU_MODINDEX(modname) << NU_PIN_MODINDEX_Pos) | NU_PIN_BIND_Msk)
sahilmgandhi 18:6a4db94011d3 41
sahilmgandhi 18:6a4db94011d3 42 #define NU_PORT_BASE(port) ((GPIO_T *)(((uint32_t) GPIOA_BASE) + 0x40 * port))
sahilmgandhi 18:6a4db94011d3 43 #define NU_MFP_POS(pin) ((pin % 8) * 4)
sahilmgandhi 18:6a4db94011d3 44 #define NU_MFP_MSK(pin) (0xful << NU_MFP_POS(pin))
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 // LEGACY
sahilmgandhi 18:6a4db94011d3 47 #define NU_PINNAME_TO_PIN(PINNAME) NU_PININDEX(PINNAME)
sahilmgandhi 18:6a4db94011d3 48 #define NU_PINNAME_TO_PORT(PINNAME) NU_PINPORT(PINNAME)
sahilmgandhi 18:6a4db94011d3 49 #define NU_PINNAME_TO_MODSUBINDEX(PINNAME) NU_PIN_MODINDEX(PINNAME)
sahilmgandhi 18:6a4db94011d3 50 #define NU_PORT_N_PIN_TO_PINNAME(PORT, PIN) NU_PINNAME((PORT), (PIN))
sahilmgandhi 18:6a4db94011d3 51
sahilmgandhi 18:6a4db94011d3 52 typedef enum {
sahilmgandhi 18:6a4db94011d3 53 PIN_INPUT,
sahilmgandhi 18:6a4db94011d3 54 PIN_OUTPUT
sahilmgandhi 18:6a4db94011d3 55 } PinDirection;
sahilmgandhi 18:6a4db94011d3 56
sahilmgandhi 18:6a4db94011d3 57 typedef enum {
sahilmgandhi 18:6a4db94011d3 58 PullNone = 0,
sahilmgandhi 18:6a4db94011d3 59 PullDown,
sahilmgandhi 18:6a4db94011d3 60 PullUp,
sahilmgandhi 18:6a4db94011d3 61
sahilmgandhi 18:6a4db94011d3 62 PushPull,
sahilmgandhi 18:6a4db94011d3 63 OpenDrain,
sahilmgandhi 18:6a4db94011d3 64 Quasi,
sahilmgandhi 18:6a4db94011d3 65
sahilmgandhi 18:6a4db94011d3 66 PullDefault = PullUp,
sahilmgandhi 18:6a4db94011d3 67 } PinMode;
sahilmgandhi 18:6a4db94011d3 68
sahilmgandhi 18:6a4db94011d3 69 typedef enum {
sahilmgandhi 18:6a4db94011d3 70 // Not connected
sahilmgandhi 18:6a4db94011d3 71 NC = (int)0xFFFFFFFF,
sahilmgandhi 18:6a4db94011d3 72
sahilmgandhi 18:6a4db94011d3 73 // Generic naming
sahilmgandhi 18:6a4db94011d3 74 PA_0 = NU_PORT_N_PIN_TO_PINNAME(0, 0), PA_1, PA_2, PA_3, PA_4, PA_5, PA_6, PA_7, PA_8, PA_9, PA_10, PA_11, PA_12, PA_13, PA_14, PA_15,
sahilmgandhi 18:6a4db94011d3 75 PB_0 = NU_PORT_N_PIN_TO_PINNAME(1, 0), PB_1, PB_2, PB_3, PB_4, PB_5, PB_6, PB_7, PB_8, PB_9, PB_10, PB_11, PB_12, PB_13, PB_14, PB_15,
sahilmgandhi 18:6a4db94011d3 76 PC_0 = NU_PORT_N_PIN_TO_PINNAME(2, 0), PC_1, PC_2, PC_3, PC_4, PC_5, PC_6, PC_7, PC_8, PC_9, PC_10, PC_11, PC_12, PC_13, PC_14, PC_15,
sahilmgandhi 18:6a4db94011d3 77 PD_0 = NU_PORT_N_PIN_TO_PINNAME(3, 0), PD_1, PD_2, PD_3, PD_4, PD_5, PD_6, PD_7, PD_8, PD_9, PD_10, PD_11, PD_12, PD_13, PD_14, PD_15,
sahilmgandhi 18:6a4db94011d3 78 PE_0 = NU_PORT_N_PIN_TO_PINNAME(4, 0), PE_1, PE_2, PE_3, PE_4, PE_5, PE_6, PE_7, PE_8, PE_9, PE_10, PE_11, PE_12, PE_13, PE_14,
sahilmgandhi 18:6a4db94011d3 79 PF_0 = NU_PORT_N_PIN_TO_PINNAME(5, 0), PF_1, PF_2, PF_3, PF_4, PF_5, PF_6, PF_7,
sahilmgandhi 18:6a4db94011d3 80
sahilmgandhi 18:6a4db94011d3 81 // Arduino UNO naming
sahilmgandhi 18:6a4db94011d3 82 A0 = PB_0,
sahilmgandhi 18:6a4db94011d3 83 A1 = PB_1,
sahilmgandhi 18:6a4db94011d3 84 A2 = PB_2,
sahilmgandhi 18:6a4db94011d3 85 A3 = PB_3,
sahilmgandhi 18:6a4db94011d3 86 A4 = PB_4,
sahilmgandhi 18:6a4db94011d3 87 A5 = PB_8,
sahilmgandhi 18:6a4db94011d3 88 A6 = PB_9,
sahilmgandhi 18:6a4db94011d3 89 A7 = PB_10,
sahilmgandhi 18:6a4db94011d3 90
sahilmgandhi 18:6a4db94011d3 91 D0 = PD_6,
sahilmgandhi 18:6a4db94011d3 92 D1 = PD_1,
sahilmgandhi 18:6a4db94011d3 93 D2 = PC_6,
sahilmgandhi 18:6a4db94011d3 94 D3 = PC_7,
sahilmgandhi 18:6a4db94011d3 95 D4 = PC_11,
sahilmgandhi 18:6a4db94011d3 96 D5 = PC_12,
sahilmgandhi 18:6a4db94011d3 97 D6 = PC_13,
sahilmgandhi 18:6a4db94011d3 98 D7 = PC_14,
sahilmgandhi 18:6a4db94011d3 99 D8 = PC_0,
sahilmgandhi 18:6a4db94011d3 100 D9 = PC_1,
sahilmgandhi 18:6a4db94011d3 101 D10 = PC_2,
sahilmgandhi 18:6a4db94011d3 102 D11 = PC_3,
sahilmgandhi 18:6a4db94011d3 103 D12 = PC_4,
sahilmgandhi 18:6a4db94011d3 104 D13 = PC_5,
sahilmgandhi 18:6a4db94011d3 105 D14 = PE_5,
sahilmgandhi 18:6a4db94011d3 106 D15 = PE_4,
sahilmgandhi 18:6a4db94011d3 107
sahilmgandhi 18:6a4db94011d3 108 // FIXME: other board-specific naming
sahilmgandhi 18:6a4db94011d3 109 // UART naming
sahilmgandhi 18:6a4db94011d3 110 USBTX = PA_8,
sahilmgandhi 18:6a4db94011d3 111 USBRX = PA_9,
sahilmgandhi 18:6a4db94011d3 112 STDIO_UART_TX = USBTX,
sahilmgandhi 18:6a4db94011d3 113 STDIO_UART_RX = USBRX,
sahilmgandhi 18:6a4db94011d3 114 // LED naming
sahilmgandhi 18:6a4db94011d3 115 LED1 = PD_2,
sahilmgandhi 18:6a4db94011d3 116 LED2 = PD_3,
sahilmgandhi 18:6a4db94011d3 117 LED3 = PD_7,
sahilmgandhi 18:6a4db94011d3 118 LED4 = D0, // No real LED. Just for passing ATS.
sahilmgandhi 18:6a4db94011d3 119 LED_RED = LED2,
sahilmgandhi 18:6a4db94011d3 120 LED_GREEN = LED3,
sahilmgandhi 18:6a4db94011d3 121 LED_BLUE = LED1,
sahilmgandhi 18:6a4db94011d3 122 // Button naming
sahilmgandhi 18:6a4db94011d3 123 SW2 = PA_15,
sahilmgandhi 18:6a4db94011d3 124 SW3 = PA_14,
sahilmgandhi 18:6a4db94011d3 125
sahilmgandhi 18:6a4db94011d3 126 } PinName;
sahilmgandhi 18:6a4db94011d3 127
sahilmgandhi 18:6a4db94011d3 128 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 129 }
sahilmgandhi 18:6a4db94011d3 130 #endif
sahilmgandhi 18:6a4db94011d3 131
sahilmgandhi 18:6a4db94011d3 132 #endif // MBED_PINNAMES_H