MyPinOp.h
#ifndef __MyPinOp_H
#define __MyPinOp_H
//#define LockPortEn
#define STM32PINA00 (0*16+0)
#define STM32PINA01 (0*16+1)
#define STM32PINA02 (0*16+2)
#define STM32PINA03 (0*16+3)
#define STM32PINA04 (0*16+4)
#define STM32PINA05 (0*16+5)
#define STM32PINA06 (0*16+6)
#define STM32PINA07 (0*16+7)
#define STM32PINA08 (0*16+8)
#define STM32PINA09 (0*16+9)
#define STM32PINA10 (0*16+10)
#define STM32PINA11 (0*16+11)
#define STM32PINA12 (0*16+12)
#define STM32PINA13 (0*16+13)
#define STM32PINA14 (0*16+14)
#define STM32PINA15 (0*16+15)
#define STM32PINB00 (1*16+0)
#define STM32PINB01 (1*16+1)
#define STM32PINB02 (1*16+2)
#define STM32PINB03 (1*16+3)
#define STM32PINB04 (1*16+4)
#define STM32PINB05 (1*16+5)
#define STM32PINB06 (1*16+6)
#define STM32PINB07 (1*16+7)
#define STM32PINB08 (1*16+8)
#define STM32PINB09 (1*16+9)
#define STM32PINB10 (1*16+10)
#define STM32PINB11 (1*16+11)
#define STM32PINB12 (1*16+12)
#define STM32PINB13 (1*16+13)
#define STM32PINB14 (1*16+14)
#define STM32PINB15 (1*16+15)
#define STM32PINC00 (2*16+0)
#define STM32PINC01 (2*16+1)
#define STM32PINC02 (2*16+2)
#define STM32PINC03 (2*16+3)
#define STM32PINC04 (2*16+4)
#define STM32PINC05 (2*16+5)
#define STM32PINC06 (2*16+6)
#define STM32PINC07 (2*16+7)
#define STM32PINC08 (2*16+8)
#define STM32PINC09 (2*16+9)
#define STM32PINC10 (2*16+10)
#define STM32PINC11 (2*16+11)
#define STM32PINC12 (2*16+12)
#define STM32PINC13 (2*16+13)
#define STM32PINC14 (2*16+14)
#define STM32PINC15 (2*16+15)
#define STM32PIND00 (3*16+0)
#define STM32PIND01 (3*16+1)
#define STM32PIND02 (3*16+2)
#define STM32PIND03 (3*16+3)
#define STM32PIND04 (3*16+4)
#define STM32PIND05 (3*16+5)
#define STM32PIND06 (3*16+6)
#define STM32PIND07 (3*16+7)
#define STM32PIND08 (3*16+8)
#define STM32PIND09 (3*16+9)
#define STM32PIND10 (3*16+10)
#define STM32PIND11 (3*16+11)
#define STM32PIND12 (3*16+12)
#define STM32PIND13 (3*16+13)
#define STM32PIND14 (3*16+14)
#define STM32PIND15 (3*16+15)
#define STM32PINE00 (4*16+0)
#define STM32PINE01 (4*16+1)
#define STM32PINE02 (4*16+2)
#define STM32PINE03 (4*16+3)
#define STM32PINE04 (4*16+4)
#define STM32PINE05 (4*16+5)
#define STM32PINE06 (4*16+6)
#define STM32PINE07 (4*16+7)
#define STM32PINE08 (4*16+8)
#define STM32PINE09 (4*16+9)
#define STM32PINE10 (4*16+10)
#define STM32PINE11 (4*16+11)
#define STM32PINE12 (4*16+12)
#define STM32PINE13 (4*16+13)
#define STM32PINE14 (4*16+14)
#define STM32PINE15 (4*16+15)
#define STM32PINF00 (5*16+0)
#define STM32PINF01 (5*16+1)
#define STM32PINF02 (5*16+2)
#define STM32PINF03 (5*16+3)
#define STM32PINF04 (5*16+4)
#define STM32PINF05 (5*16+5)
#define STM32PINF06 (5*16+6)
#define STM32PINF07 (5*16+7)
#define STM32PINF08 (5*16+8)
#define STM32PINF09 (5*16+9)
#define STM32PINF10 (5*16+10)
#define STM32PINF11 (5*16+11)
#define STM32PINF12 (5*16+12)
#define STM32PINF13 (5*16+13)
#define STM32PINF14 (5*16+14)
#define STM32PINF15 (5*16+15)
#define STM32PING00 (6*16+0)
#define STM32PING01 (6*16+1)
#define STM32PING02 (6*16+2)
#define STM32PING03 (6*16+3)
#define STM32PING04 (6*16+4)
#define STM32PING05 (6*16+5)
#define STM32PING06 (6*16+6)
#define STM32PING07 (6*16+7)
#define STM32PING08 (6*16+8)
#define STM32PING09 (6*16+9)
#define STM32PING10 (6*16+10)
#define STM32PING11 (6*16+11)
#define STM32PING12 (6*16+12)
#define STM32PING13 (6*16+13)
#define STM32PING14 (6*16+14)
#define STM32PING15 (6*16+15)
//CRH/CRL:0 AIN;1 GPPO_10MHz;2 GPPO_2MHz;3 GPPO_50MHz
//4 IN ;5 GOCO_10MHz;6 GOCO_2MHz;7 GOCO_50MHz
//8 IPP;9 APPO_10MHz;a APPO_2MHz;b APPO_50MHz
//c NA ;d AOCO_10MHz;e AOCO_2MHz;f AOCO_50MHz
typedef enum
{
PinMode_AIN=0,
PinMode_GPPO_10MHz=1,
PinMode_GPPO_2MHz=2,
PinMode_GPPO_50MHz=3,
PinMode_IN=4,
PinMode_GOCO_10MHz=5,
PinMode_GOCO_2MHz=6,
PinMode_GOCO_50MHz=7,
PinMode_IPP=8,
PinMode_APPO_10MHz=9,
PinMode_APPO_2MHz=10,
PinMode_APPO_50MHz=11,
PinMode_NA=12,
PinMode_AOCO_10MHz=13,
PinMode_AOCO_2MHz=14,
PinMode_AOCO_50MHz=15,
}TStmPinMode;
void SetPinMode(unsigned char Pin,TStmPinMode mode);
unsigned long PinIdr(unsigned char Pin);
unsigned long PinOdr(unsigned char Pin);
void SetPin(unsigned char Pin);
void ClrPin(unsigned char Pin);
void SpinPin(unsigned char Pin);
unsigned long LockPin(unsigned char Pin);
unsigned long UnlockPin(unsigned char Pin);
unsigned long LockPort(unsigned char Pin);
#include "CortexM3_Bitband_DEF.h"
#define IDRBB(stm32pin) ((*((vu32 *) BITBAND_PERI((((stm32pin/16)*0x400+GPIOA_BASE)+0x08),stm32pin%16))))
#define ODRBB(stm32pin) ((*((vu32 *) BITBAND_PERI((((stm32pin/16)*0x400+GPIOA_BASE)+0x0c),stm32pin%16))))
#define EXTIPRBB(stm32pin) ((*((vu32 *) BITBAND_PERI(((EXTI_BASE)+0x14),stm32pin%16))))
#endif
#ifndef __CortexM3_Bitband_DEF_H
#define __CortexM3_Bitband_DEF_H
#define BITBAND_SRAM_REF 0x20000000
#define BITBAND_SRAM_BASE 0x22000000
#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + (a-BITBAND_SRAM_REF)*32 + (b*4))) // Convert SRAM address
#define BITBAND_PERI_REF 0x40000000
#define BITBAND_PERI_BASE 0x42000000
#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + (a-BITBAND_PERI_REF)*32 + (b*4))) // Convert PERI address
#endif