本帖最后由 740071911 于 2021-3-25 23:41 编辑
AC781x系列基于cortex-m3内核车规级mcu,很厉害呀,看看介绍:
拿到板子,看下电路图,直接点灯
LED2 -- PB9
LED3 -- PB10
建立工程(这个组件管理真的超好用,强烈推荐,直接勾上外设库就行了)
上代码,gpio.h
#ifndef __GPIO_H_
#define __GPIO_H_
#include "ac78xx_gpio.h"
/* makesure n < 16 */
#define PAout(n) BIT_ADDR(GPIOA_ODR_ADDR, n)
#define PAin(n) BIT_ADDR(GPIOA_IDR_ADDR, n)
#define PBout(n) BIT_ADDR(GPIOB_ODR_ADDR, n)
#define PBin(n) BIT_ADDR(GPIOB_IDR_ADDR, n)
#define PCout(n) BIT_ADDR(GPIOC_ODR_ADDR, n)
#define PCin(n) BIT_ADDR(GPIOC_IDR_ADDR, n)
#define PDout(n) BIT_ADDR(GPIOD_ODR_ADDR, n)
#define PDin(n) BIT_ADDR(GPIOD_IDR_ADDR, n)
#define PEout(n) BIT_ADDR(GPIOE_ODR_ADDR, n)
#define PEin(n) BIT_ADDR(GPIOE_IDR_ADDR, n)
/* gpio bit-band control */
#define LED2 PBout(9)
#define LED3 PBout(10)
#define KEY6 PAin(11)
#define KEY7 PAin(12)
/* define key gpio */
#define PIN_K6 GPIO_PA11
#define PIN_K7 GPIO_PA12
/* define LED gpio */
#define PIN_LED2 GPIO_PB9
#define PIN_LED3 GPIO_PB10
void LED_Init(void);
#endif
gpio.c
#include "gpio.h"
/**
* LED_Init
*
* @param[in] none
* [url=home.php?mod=space&uid=266161]@return[/url] none
*
* [url=home.php?mod=space&uid=247401]@brief[/url] init led control gpio
*
*/
void LED_Init(void)
{
/* init gpio as output mode */
GPIO_SetDir((uint32_t)PIN_LED2, 1);
GPIO_SetDir((uint32_t)PIN_LED3, 1);
}
main.c
#include "gpio.h"
int main(void)
{
LED_Init();
while(1)
{
LED2 = 1;
for(int i=0; i<0x5fffff; i++);
LED2 = 0;
for(int i=0; i<0x5fffff; i++);
}
}
简单粗暴!完事。
|