日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]之前做的PCB板回來(lái)前,需構(gòu)建“驅(qū)動(dòng)代碼”的“架構(gòu)”問(wèn)題,相對(duì)簡(jiǎn)單,按流程圖整理出的文件截圖共2頁(yè),具體如下:第1頁(yè):第2頁(yè):--------------------------華麗分割線 1-------------------------編程使用的“版本”

之前做的PCB板回來(lái)前,需構(gòu)建“驅(qū)動(dòng)代碼”的“架構(gòu)”問(wèn)題,相對(duì)簡(jiǎn)單,按流程圖整理出的文件截圖共2頁(yè),具體如下:

第1頁(yè):

第2頁(yè):

--------------------------華麗分割線 1-------------------------

編程使用的“版本”為“IAR for STM8 1401”,使用還不錯(cuò),比較順手,由于已經(jīng)完成過(guò)部分驅(qū)動(dòng),并將所有頭文件封裝進(jìn)"includes.h"中,包含的頭文件如下:

#ifndef __INCLUDES_H_FOR_STM8

#define __INCLUDES_H_FOR_STM8

#include"ultra_maps.h"

#include"ultra_edit.h"

#include "stm8s.h"

#include "stm8s_clk.h"

#include "stm8s_gpio.h"

#include "delay.h"

#include "bsp_gpio.h"

#include "bsp_key.h"

#include "bsp_usart.h"

#include "bsp_adc.h"

#include "bsp_adc_multi.h"

#include "bsp_tim1.h"

#include "bsp_tim2.h"

#include "bsp_tim4.h"

#include "bsp_relay.h"

#endif

控制“功率LED”使用代碼位于“bsp_relay.h”和“bsp_relay.c”中,代碼很多,采用“宏定義”實(shí)現(xiàn)有效控制,“宏定義”如下:

#define RELAY01_GPIO_PORT (GPIOC)

#define RELAY01_GPIO_PINS (GPIO_PIN_7)

#define RELAY02_GPIO_PORT (GPIOC)

#define RELAY02_GPIO_PINS (GPIO_PIN_6)

#define RELAY03_GPIO_PORT (GPIOC)

#define RELAY03_GPIO_PINS (GPIO_PIN_5)

#define RELAY04_GPIO_PORT (GPIOC)

#define RELAY04_GPIO_PINS (GPIO_PIN_4)

#define RELAY05_GPIO_PORT (GPIOC)

#define RELAY05_GPIO_PINS (GPIO_PIN_3)

#define RELAY06_GPIO_PORT (GPIOB)

#define RELAY06_GPIO_PINS (GPIO_PIN_4)

#define RELAY07_GPIO_PORT (GPIOB)

#define RELAY07_GPIO_PINS (GPIO_PIN_5)

“bsp_relay.c”中使用的所有函數(shù)如下:

void Relay_GPIO_Init(void);

void Relay_Left_ALL_ON(void);

void Relay_Left_ALL_OFF(void);

void Relay_Left_Single_ON(uint8_t numOfPin);

void Relay_Left_Single_OFF(uint8_t numOfPin);

void Relay_Right_ALL_ON(void);

void Relay_Right_ALL_OFF(void);

void Relay_Right_Single_ON(uint8_t numOfPin);

void Relay_Right_Single_OFF(uint8_t numOfPin);

void Relay_Left_Right_USART1_Action(uint8_t numOfPin);

看“函數(shù)名”大概就可以知道函數(shù)功能,以下是“void Relay_Left_Single_ON(uint8_t numOfPin)”函數(shù)代碼,其他函數(shù)代碼均按照此結(jié)構(gòu)編寫(xiě):

void Relay_Left_Single_ON(uint8_t numOfPin)

{

uint8_t temp = 0;

temp = numOfPin;

switch(temp)

{

case 1:

{

GPIO_WriteHigh(RELAY04_GPIO_PORT, RELAY04_GPIO_PINS);

break;

}

case 2:

{

GPIO_WriteHigh(RELAY05_GPIO_PORT, RELAY05_GPIO_PINS);

break;

}

case 3:

{

GPIO_WriteHigh(RELAY06_GPIO_PORT, RELAY06_GPIO_PINS);

break;

}

default:

{

Relay_Left_ALL_OFF();

break;

}

}

}

函數(shù)均不復(fù)雜,但“分而治之”的方式還是讓人受益良多;在后期“修改/調(diào)試代碼”時(shí),簡(jiǎn)直不要太愉快;


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉