kwseeker

学编程:找代码,读代码,改代码,写代码;少看书。但少看不是不看,看一本书要限制在一天内。任务是通读书中主要的概念,明白大致是干什么用的,形成一个大概的框架;然后一周内干掉书中全部代码,代码不理解再浏览书中相关章节,注意是浏览。或者刷博客。代码实在刷不懂,可以先刷后面,待日后重新刷;因为书中代码有些部分可能出自后面的章节。代码总是在多次刷过之后,拨开乌云见日月的。。。

导航

ARM1138@库函数速查

1. GPIO库函数

  可实现的功能:

  获得/设置指定管脚的方向(输入、输出)和模式(硬件控制)

 获取/设置指定管脚的配置(驱动强度2/4/8/8_SCmA、管脚模式:推挽(弱上拉/弱下拉)/开漏(弱上拉/弱下拉)/模拟输入)

 读取/写入管脚上值

  ——————————————

 使能/关闭/清除相应管脚的中断

 获取/设置管脚的中断类型(高电平、低电平、上升沿、下降沿、双边沿)

 获取GPIO端口的中断状态(屏蔽的还是原始的中断状态)

 注册/注销GPIO端口的一个中断处理程序

 —————————————— 

 配置管脚,使其作为(模数转换输入使用/一个CAN器件/一个模拟比较器的输入/GPIO输入/GPIO输出/GPIO开漏输出/供I2C外设使用/供PWM外设使用/供QEI外设使用/供SSI外设使用/供定时器外设使用/供UART外设使用/供USB外设使用  )

 

  库函数声明结构:

  unsigned long GPIODirModeGet (unsigned long ulPort, unsigned char ucPin);
  void      GPIODirModeSet (unsigned long ulPort, unsigned char ucPins,unsigned long ulPinIO);
  void      GPIOPadConfigGet (unsigned long ulPort, unsigned char ucPin, unsigned long*pulStrength, unsigned long *pulPinType);
  void      GPIOPadConfigSet (unsigned long ulPort, unsigned char ucPins,unsigned long ulStrength, unsigned long ulPinType);

  long      GPIOPinRead (unsigned long ulPort, unsigned char ucPins);

  void      GPIOPinWrite (unsigned long ulPort, unsigned char ucPins, unsigned char ucVal);

  ——————————————

 void      GPIOPinIntClear (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinIntDisable (unsigned long ulPort, unsigned char ucPins);

  unsigned long GPIOIntTypeGet (unsigned long ulPort, unsigned char ucPin);
  void      GPIOIntTypeSet (unsigned long ulPort, unsigned char ucPins, unsigned long ulIntType);

  void      GPIOPinIntEnable (unsigned long ulPort, unsigned char ucPins);
  long      GPIOPinIntStatus (unsigned long ulPort, tBoolean bMasked);

  void      GPIOPortIntRegister (unsigned long ulPort, void (*pfnIntHandler)(void));
  void      GPIOPortIntUnregister (unsigned long ulPort)

  ——————————————

  void      GPIOPinTypeADC (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeCAN (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeComparator (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeGPIOInput (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeGPIOOutput (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeGPIOOutputOD (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeI2C (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypePWM (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeQEI (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeSSI (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeTimer (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeUART (unsigned long ulPort, unsigned char ucPins);
  void      GPIOPinTypeUSBDigital (unsigned long ulPort, unsigned char ucPins);

int iVal;
// // 注册端口级别的中断处理程序。对于所有管脚中断来说,这个处理程序是所有管脚中断的 // 第一级别的中断处理程序。 // GPIOPortIntRegister(GPIO_PORTA_BASE, PortAIntHandler);
// // 初始化GPIO管脚配置。 // // 设置管脚2、 4和5作为输入,由软件控制。 // GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5);
// // 设置管脚0和3作为输出,软件控制。 // GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_3);
// // 使得在管脚2和4的上升沿触发中断。 // GPIOIntTypeSet(GPIO_PORTA_BASE, (GPIO_PIN_2 | GPIO_PIN_4),GPIO_RISING_EDGE);
// // 使得在管脚5的高电平触发中断。 // GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_5, GPIO_HIGH_LEVEL);
// // 读取一些管脚。 // iVal = GPIOPinRead(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 |GPIO_PIN_4 | GPIO_PIN_5));
// // 写一些管脚。尽管管脚2、4和5被指定,它们也不受这个写操作的影响,因为它们配置用作输入。 // 在这个写操作结束时,管脚0的值将为0,管脚3的值将为1。 // GPIOPinWrite(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 |GPIO_PIN_4 | GPIO_PIN_5), 0xF4);
// // 使能管脚中断。 // GPIOPinIntEnable(GPIO_PORTA_BASE, (GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5));

  

 

2. Timer库函数 src/timer.c src/timer.h

  实现的功能:

  配置定时器(32 位单次触发定时器/32 位周期定时器/32 位实时时钟定时器/2 个 16 位的定时器/16 位的单次触发定时器/16 位的周期定时器/16 位的边沿计数捕获/16 位的边沿时间捕获/16 位 PWM 输出/TIMER_CFG_B_*值和 ulConfig 的逻辑或)

  在捕获模式中触发定时器的信号沿(TIMER_EVENT_POS_EDGE 、TIMER_EVENT_NEG_EDGE 或 TIMER_EVENT_BOTH_EDGES)

  设置指定定时器的 PWM 输出电平(Ture低电平,false高电平)  

  控制指定定时器的停止响应。如果 bStall 参数为 True,则定时器将在处理器进入调试模式时停止计数;否则,在调试模式中定时器将继续运行

  控制指定定时器的触发输出。如果参数 bEnable 为 True,则使能定时器的输出触发;否则,禁止定时器的输出触发

  使能/禁止定时器

  清除指定的定时器中断源,使其不再有效。这必须在中断处理程序中处理,以防在退出时再次对其立即进行调用。

  使能/禁止单个定时器中断源

  注销/注册一个定时器中断的中断处理程序

  获取当前的中断状态

  设置/获取定时器装载值

  设置/获取定时器匹配值

  设置/获取定时器预分频器的值

  禁止 RTC 计数

  获取当前的定时器值

  库函数声明结构: 

    void        TimerConfigure (unsigned long ulBase, unsigned long ulConfig);
    void        TimerControlEvent (unsigned long ulBase, unsigned long ulTimer, unsigned long ulEvent);
􀁺  void        TimerControlLevel (unsigned long ulBase, unsigned long ulTimer, tBoolean bInvert);
􀁺  void       TimerControlStall (unsigned long ulBase, unsigned long ulTimer, tBoolean bStall);
􀁺  void       TimerControlTrigger (unsigned long ulBase, unsigned long ulTimer, tBoolean bEnable);
􀁺  void        TimerDisable (unsigned long ulBase, unsigned long ulTimer);
􀁺  void        TimerEnable (unsigned long ulBase, unsigned long ulTimer);
􀁺  void        TimerIntClear (unsigned long ulBase, unsigned long ulIntFlags);
􀁺  void        TimerIntDisable (unsigned long ulBase, unsigned long ulIntFlags);
􀁺  void       TimerIntEnable (unsigned long ulBase, unsigned long ulIntFlags);
􀁺  void       TimerIntRegister (unsigned long ulBase, unsigned long ulTimer, void (*pfnHandler)(void));

􀁺  unsigned long  TimerIntStatus (unsigned long ulBase, tBoolean bMasked);
􀁺  void        TimerIntUnregister (unsigned long ulBase, unsigned long ulTimer);
􀁺  unsigned long  TimerLoadGet (unsigned long ulBase, unsigned long ulTimer);
􀁺  void        TimerLoadSet (unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue);
􀁺  unsigned long  TimerMatchGet (unsigned long ulBase, unsigned long ulTimer);
􀁺  void       TimerMatchSet (unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue);
􀁺  unsigned long  TimerPrescaleGet (unsigned long ulBase, unsigned long ulTimer);
􀁺  void       TimerPrescaleSet (unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue);
􀁺  void       TimerRTCDisable (unsigned long ulBase);
􀁺  void       TimerRTCEnable (unsigned long ulBase);
 􀁺 unsigned long  TimerValueGet (unsigned long ulBase, unsigned long ulTimer)

//
// 将 TimerA 配置用作一个 16 位的单次触发定时器,TimerB 配置用作一个 16 位的边沿捕获计数器。
//
TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_ONE_SHOT | TIMER_CFG_B_CAP_COUNT));
// // 配置计数器(TimerB),对两个边沿进行计数。 // TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_BOTH_EDGES);
// // 使能定时器。 // TimerEnable(TIMER0_BASE, TIMER_BOTH);

 

3. 系统节拍库函数 src/systick.c src/systick.h

  实现的功能

  使能/禁止 SysTick 计数器

  使能/禁止 SysTick 中断

  注销/注册一个 SysTick 中断的中断处理程序

  设置/获取 SysTick 计数器的周期

  获取 SysTick 计数器的当前值

  库函数声明结构

􀁺 void       SysTickDisable (void);
􀁺 void       SysTickEnable (void);
􀁺 void       SysTickIntDisable (void);
􀁺 void       SysTickIntEnable (void);
􀁺 void       SysTickIntRegister (void (*pfnHandler)(void));
􀁺 void       SysTickIntUnregister (void);
􀁺 unsigned long SysTickPeriodGet (void);
􀁺 void       SysTickPeriodSet (unsigned long ulPeriod);
􀁺 unsigned long SysTickValueGet (void);

unsigned long ulValue;
//
// 配置和使能 SysTick 计数器。
//
SysTickPeriodSet(1000);
SysTickEnable();
//
// 延时一段时间…
//
// 读取当前的 SysTick 值。
//
ulValue = SysTickValueGet();

 

4. 系统控制

  实现功能

  SysCtl API 分成 8 组,它们完成 8 种以下功能:提供器件信息、处理器件时钟、提供外设控制、处理 SysCtl 中断、处理 LDO、处理睡眠模式、处理复位源、处理掉电复位、处理时钟验证定时器。
  器件的相关信息由 SysCtlSRAMSizeGet()、SysCtlFlashSizeGet()、SysCtlPeripheralPresent()和 SysCtlPinPresent()来提供。
器件的时钟由 SysCtlClockSet()和 SysCtlPWMClockSet()来配置。器件的时钟信息由SysCtlClockGet()和 SysCtlPWMClockGet()来提供。
  外 设 使 能 和 复 位 由 SysCtlPeripheralReset() 、 SysCtlPeripheralEnable() 、 SysCtlPeripheralDisable() 、 SysCtlPeripheralSleepEnable() 、 SysCtlPeripheralSleepDisable() 、 SysCtlPeripheralDeepSleepEnable() 、 SysCtlPeripheralDeepSleepDisable() 和 SysCtlPeripheralClock
-Gating()来控制。
  系 统 控 制 中 断 由 SysCtlIntRegister() 、 SysCtlIntUnregister() 、 SysCtlIntEnable() 、SysCtlIntDisable()、SysCtlIntClear()和 SysCtlIntStatus()来管理。
  LDO 由 SysCtlLDOSet()和 SysCtlLDOConfigSet()来控制。它的状态由 SysCtlLDOGet()来提供。
  SysCtlSleep()和 SysCtlDeepSleep()使器件进入睡眠模式
  复 位 源 由 SysCtlResetCauseGet() 和 SysCtlResetCauseClear() 来 管 理 。 软 件 复 位 由SysCtlReset()来执行。
  掉电复位由 SysCtlBrownOutConfigSet()来配置。
  时 钟 验 证 定 时 器 由 SysCtlIOSCVerificationSet() 、 SysCtlMOSCVerificationSet() 、SysCtlPLLVerificationSet()和 SysCtlClkVerificationClear()来管理。

  库函数声明结构

􀁺 unsigned long  SysCtlADCSpeedGet (void);
􀁺 void       SysCtlADCSpeedSet (unsigned long ulSpeed);
􀁺 void       SysCtlBrownOutConfigSet (unsigned long ulConfig, unsigned long ulDelay);
􀁺 void       SysCtlClkVerificationClear (void);
􀁺 unsigned long  SysCtlClockGet (void);
􀁺 void       SysCtlClockSet (unsigned long ulConfig);
􀁺 void       SysCtlDeepSleep (void);
􀁺 void       SysCtlDelay (unsigned long ulCount);
􀁺 unsigned long   SysCtlFlashSizeGet (void);
􀁺 void       SysCtlGPIOAHBDisable (unsigned long ulGPIOPeripheral);
􀁺 void       SysCtlGPIOAHBEnable (unsigned long ulGPIOPeripheral);
􀁺 void       SysCtlIntClear (unsigned long ulInts);
􀁺 void       SysCtlIntDisable (unsigned long ulInts);
􀁺 void       SysCtlIntEnable (unsigned long ulInts);
􀁺 void       SysCtlIntRegister (void (*pfnHandler)(void));
􀁺 unsigned long   SysCtlIntStatus (tBoolean bMasked);
􀁺 void       SysCtlIntUnregister (void);
􀁺 void       SysCtlIOSCVerificationSet (tBoolean bEnable);
􀁺 void       SysCtlLDOConfigSet (unsigned long ulConfig);
􀁺 unsigned long   SysCtlLDOGet (void);
􀁺 void       SysCtlLDOSet (unsigned long ulVoltage);
􀁺 void       SysCtlMOSCVerificationSet (tBoolean bEnable);
􀁺 void       SysCtlPeripheralClockGating (tBoolean bEnable);
􀁺 void       SysCtlPeripheralDeepSleepDisable (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralDeepSleepEnable (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralDisable (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralEnable (unsigned long ulPeripheral);
􀁺 tBoolean     SysCtlPeripheralPresent (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralReset (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralSleepDisable (unsigned long ulPeripheral);
􀁺 void       SysCtlPeripheralSleepEnable (unsigned long ulPeripheral);
􀁺 tBoolean     SysCtlPinPresent (unsigned long ulPin);
􀁺 void       SysCtlPLLVerificationSet (tBoolean bEnable);
􀁺 unsigned long   SysCtlPWMClockGet (void);
􀁺 void       SysCtlPWMClockSet (unsigned long ulConfig);
􀁺 void       SysCtlReset (void);
􀁺 void       SysCtlResetCauseClear (unsigned long ulCauses);
􀁺 unsigned long   SysCtlResetCauseGet (void);
􀁺 void       SysCtlSleep (void);
􀁺 unsigned long   SysCtlSRAMSizeGet (void);
􀁺 void       SysCtlUSBPLLDisable (void);

􀁺 void       SysCtlUSBPLLEnable (void);

 

5. 中断控制器 src/interrupt.c src/interrupt.h

  实现功能

  使能/禁止一个中断

  使能/禁止处理器中断

  获取一个中断的优先级

  获取中断控制器的优先级分组

  设置中断控制器的优先级分组

  设置一个中断的优先级

  注销/注册一个在中断出现时被调用的函数  

  库函数声明结构 

􀁺 void     IntDisable (unsigned long ulInterrupt);
􀁺 void     IntEnable (unsigned long ulInterrupt);
􀁺 tBoolean   IntMasterDisable (void);
􀁺 tBoolean   IntMasterEnable (void);
􀁺 long     IntPriorityGet (unsigned long ulInterrupt);

􀁺 unsigned long IntPriorityGroupingGet (void);
􀁺 void     IntPriorityGroupingSet (unsigned long ulBits);
􀁺 void     IntPrioritySet (unsigned long ulInterrupt, unsigned char ucPriority);
􀁺 void     IntRegister (unsigned long ulInterrupt, void (*pfnHandler)(void));
􀁺 void     IntUnregister (unsigned long ulInterrupt);

//
// 中断处理程序函数。
//
extern void IntHandler(void);
//
// 注册中断5的中断处理程序函数。
//
IntRegister(5, IntHandler);
//
// 使能中断5。
//
IntEnable(5);
//
// 使能中断5。
//
IntMasterEnable();

  

6. PWM src/pwm.c  src/pwm.h

 实现功能

 

  库函数声明结构

􀁺 void     PWMDeadBandDisable (unsigned long ulBase, unsigned long ulGen);
􀁺 void     PWMDeadBandEnable (unsigned long ulBase, unsigned long ulGen, unsigned short usRise, unsigned short usFall);
􀁺 void     PWMFaultIntClear (unsigned long ulBase);
􀁺 void     PWMFaultIntClearExt (unsigned long ulBase, unsigned long ulFaultInts);
􀁺 void     PWMFaultIntRegister (unsigned long ulBase, void (*pfnIntHandler)(void));
􀁺 void     PWMFaultIntUnregister (unsigned long ulBase);
􀁺 void     PWMGenConfigure (unsigned long ulBase, unsigned long ulGen, unsigned long ulConfig);
􀁺 void     PWMGenDisable (unsigned long ulBase, unsigned long ulGen);
􀁺 void     PWMGenEnable (unsigned long ulBase, unsigned long ulGen);

􀁺 unsigned long PWMGenFaultTriggerGet (unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup);
􀁺 void     PWMGenFaultTriggerSet (unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup, unsigned long ulFaultTriggers);
􀁺 void     PWMGenIntClear (unsigned long ulBase, unsigned long ulGen, unsigned long ulInts);
􀁺 void     PWMGenIntRegister (unsigned long ulBase, unsigned long ulGen, void (*pfnIntHandler)(void));
􀁺 unsigned long PWMGenIntStatus (unsigned long ulBase, unsigned long ulGen, tBoolean bMasked);
􀁺 void     PWMGenIntTrigDisable (unsigned long ulBase, unsigned long ulGen, unsigned long ulIntTrig);
􀁺 void     PWMGenIntTrigEnable (unsigned long ulBase, unsigned long ulGen, unsigned long ulIntTrig);
􀁺 void     PWMGenIntUnregister (unsigned long ulBase, unsigned long ulGen);
􀁺 unsigned long PWMGenPeriodGet (unsigned long ulBase, unsigned long ulGen);
􀁺 void     PWMGenPeriodSet (unsigned long ulBase, unsigned long ulGen, unsigned long ulPeriod);
􀁺 void     PWMIntDisable (unsigned long ulBase, unsigned long ulGenFault);
􀁺 void     PWMIntEnable (unsigned long ulBase, unsigned long ulGenFault);
􀁺 unsigned long PWMIntStatus (unsigned long ulBase, tBoolean bMasked);
􀁺 void     PWMOutputFault (unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bFaultSuppress);
􀁺 void     PWMOutputFaultLevel (unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bDriveHigh);
􀁺 void     PWMOutputInvert (unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bInvert);
􀁺 void     PWMOutputState (unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bEnable);
􀁺 unsigned long PWMPulseWidthGet (unsigned long ulBase, unsigned long ulPWMOut);
􀁺 void     PWMPulseWidthSet (unsigned long ulBase, unsigned long ulPWMOut, unsigned long ulWidth);
􀁺 void     PWMSyncTimeBase (unsigned long ulBase, unsigned long ulGenBits);
􀁺 void     PWMSyncUpdate (unsigned long ulBase, unsigned long ulGenBits)。

􀁺 void     PWMGenFaultClear (unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup,unsigned long ulFaultTriggers);
􀁺 void     PWMGenFaultConfigure (unsigned long ulBase, unsigned long ulGen, unsigned long ulMinFaultPeriod, unsigned long ulFaultSenses);
􀁺 unsigned long PWMGenFaultStatus (unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup);



posted on 2015-05-13 13:32  kwseeker  阅读(414)  评论(0编辑  收藏  举报