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

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] 1,開(kāi)發(fā)環(huán)境 1,適用芯片:STM32F4全部芯片 2,固件庫(kù):STM32F4xx_DSP_StdPeriph_Lib_V1.8.0 3,IDE:MDK5172,驅(qū)動(dòng)源碼 Delay.h文件/*************************************************************

1,開(kāi)發(fā)環(huán)境

1,適用芯片:STM32F4全部芯片

2,固件庫(kù):STM32F4xx_DSP_StdPeriph_Lib_V1.8.0

3,IDE:MDK517


2,驅(qū)動(dòng)源碼

Delay.h文件

/****************************************************************

* Copyright (C) 2016, XinLi, all right reserved.

* File name: Delay.h

* Date: 2016.03.22

* Description: Delay Driver

*****************************************************************/

#ifndef __DELAY_H

#define __DELAY_H

/****************************************************************

* Header include

*****************************************************************/

#include "stm32f4xx.h"

/****************************************************************

* Macro definition

*****************************************************************/

/****************************************************************

* Type definition

*****************************************************************/

/****************************************************************

* Structure definition

*****************************************************************/

#ifdef __cplusplus

extern "C" {

#endif /* __cplusplus */

/****************************************************************

* Variable declaration

*****************************************************************/

/****************************************************************

* Function declaration

*****************************************************************/

void Delay_us(uint64_t nus);

void Delay_ms(uint64_t nms);

void Delay_s(uint64_t ns);

#ifdef __cplusplus

}

#endif /* __cplusplus */

#endif /* __DELAY_H */


Delay.c文件

/****************************************************************

* Copyright (C) 2016, XinLi, all right reserved.

* File name: Delay.c

* Date: 2016.03.22

* Description: Delay Driver

*****************************************************************/

/****************************************************************

* Header include

*****************************************************************/

#include "Delay.h"

/****************************************************************

* Global variables

*****************************************************************/

/****************************************************************

* Function declaration

*****************************************************************/

static void Delay_Init(void);

/****************************************************************

* Function definition

*****************************************************************/

/****************************************************************

* Function: Delay_Init

* Description: Delay Configuration.

* Input:

* Output:

* Return:

*****************************************************************/

static void Delay_Init(void)

{

static uint8_t first = 0;

if(first == 0)

{

first = 1;

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);

SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; /* Disability SysTick counter */

}

}

/****************************************************************

* Function: Delay_us

* Description: Microsecond delay.

* Input: nus

* Output:

* Return:

*****************************************************************/

void Delay_us(uint64_t nus)

{

uint32_t temp = 0;

uint64_t nms = 0;

Delay_Init();

if(nus == 0)

{

return;

}

nms = nus / 1000;

nus = nus % 1000;

if(nms > 0)

{

Delay_ms(nms);

}

if(nus > 0)

{

SysTick->LOAD = SystemCoreClock / 8000000 * nus; /* Time load (SysTick-> LOAD is 24bit) */

SysTick->VAL = 0x000000; /* Empty counter */

SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; /* Start the countdown */

do

{

temp = SysTick->CTRL;

}

while(temp&0x01 && !(temp&(1<<16))); /* Wait time is reached */

SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; /* Close Counter */

SysTick->VAL = 0x000000; /* Empty counter */

}

}

/****************************************************************

* Function: Delay_ms

* Description: Millisecond delay.

* Input: nms

* Output:

* Return:

*****************************************************************/

void Delay_ms(uint64_t nms)

{

uint32_t temp = 0;

Delay_Init();

if(nms == 0)

{

return;

}

while(nms > 500)

{

SysTick->LOAD = SystemCoreClock / 8000 * 500; /* Time load (SysTick-> LOAD is 24bit) */

SysTick->VAL = 0x000000; /* Empty counter */

SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; /* Start the countdown */

do

{

temp = SysTick->CTRL;

}

while(temp&0x01 && !(temp&(1<<16))); /* Wait time is reached */

SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; /* Close Counter */

SysTick->VAL = 0x000000; /* Empty counter */

nms -= 500;

}

SysTick->LOAD = SystemCoreClock / 8000 * nms; /* Time load (SysTick-> LOAD is 24bit) */

SysTick->VAL = 0x000000; /* Empty counter */

SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; /* Start the countdown */

do

{

temp = SysTick->CTRL;

}

while(temp&0x01 && !(temp&(1<<16))); /* Wait time is reached */

SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; /* Close Counter */

SysTick->VAL = 0x000000; /* Empty counter */

}

/****************************************************************

* Function: Delay_s

* Description: Second delay.

* Input: ns

* Output:

* Return:

*****************************************************************/

void Delay_s(uint64_t ns)

{

while(ns > 0)

{

Delay_ms(1000);

ns--;

}

}



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

北京——2024年10月29日 亞馬遜云科技日前宣布,通過(guò)與光環(huán)新網(wǎng)與西云數(shù)據(jù)的緊密合作,在亞馬遜云科技(北京)區(qū)域和(寧夏)區(qū)域推出Amazon Lambda SnapStart功能,將基于Java Lambda函數(shù)的...

關(guān)鍵字: 函數(shù) 數(shù)據(jù)處理

北京2024年10月29日 /美通社/ -- 亞馬遜云科技日前宣布,通過(guò)與光環(huán)新網(wǎng)與西云數(shù)據(jù)的緊密合作,在亞馬遜云科技(北京)區(qū)域和(寧夏)區(qū)域推出Amazon Lambda SnapStart功能,將基于Java La...

關(guān)鍵字: START 亞馬遜 PS 函數(shù)

關(guān)于數(shù)據(jù)分析與可視化,以下介紹Pandas讀取數(shù)據(jù)以及保存數(shù)據(jù)的方法,畢竟我們很多時(shí)候需要讀取各種形式的數(shù)據(jù),以及將我們需要將所做的統(tǒng)計(jì)分析保存成特定的格式。

關(guān)鍵字: 函數(shù) Panda

深圳2024年8月15日 /美通社/ -- 近日,知名量化交易平臺(tái)水母量化正式推出了突破性的輪動(dòng)交易策略回測(cè)功能,目前已進(jìn)入公測(cè)階段。該功能實(shí)現(xiàn)了從策略設(shè)計(jì)、歷史回測(cè)到實(shí)盤(pán)自動(dòng)交易一體化流程,幫用戶(hù)解決了策略驗(yàn)證難、交易...

關(guān)鍵字: 編程 仿真 函數(shù) 開(kāi)源

Python由荷蘭數(shù)學(xué)和計(jì)算機(jī)科學(xué)研究學(xué)會(huì)的吉多·范羅蘇姆于1990年代初設(shè)計(jì),作為一門(mén)叫做ABC語(yǔ)言的替代品。 Python提供了高效的高級(jí)數(shù)據(jù)結(jié)構(gòu),還能簡(jiǎn)單有效地面向?qū)ο缶幊獭?/p> 關(guān)鍵字: python 函數(shù) 對(duì)象編程

測(cè)試數(shù)據(jù)綜合分析的絕佳工具,深受工程師和研究員歡迎

關(guān)鍵字: 后處理分析軟件 向?qū)?/a> 函數(shù)

由上圖中可以知道進(jìn)程地址空間中最頂部的段是棧,代碼中調(diào)用函數(shù)、定義局部變量(但不包含static修飾的變量)或聲明的類(lèi)的實(shí)例等等都要使用??臻g,當(dāng)函數(shù)執(zhí)行完(也就是程序執(zhí)行超過(guò)了這個(gè)函數(shù)的作用范圍的時(shí)候),操作系統(tǒng)會(huì)把該...

關(guān)鍵字: 進(jìn)程地址 局部變量 函數(shù)

星標(biāo)/置頂?公眾號(hào),硬核文章第一時(shí)間送達(dá)!鏈接|?https://zhuanlan.zhihu.com/p/274473971題很多,先上題后上答案,便于大家思考問(wèn)題點(diǎn):1、C和C的特點(diǎn)與區(qū)別?2、C的多態(tài)3、虛函數(shù)實(shí)現(xiàn)...

關(guān)鍵字: 騰訊 函數(shù) 進(jìn)程 AI

程序接口是操作系統(tǒng)為用戶(hù)提供的兩類(lèi)接口之一,編程人員在程序中通過(guò)程序接口來(lái)請(qǐng)求操作系統(tǒng)提供服務(wù)。面向過(guò)程語(yǔ)言最基本的單元是過(guò)程和函數(shù)。

關(guān)鍵字: 程序接口 過(guò)程 函數(shù)

星標(biāo)「嵌入式大雜燴」,一起進(jìn)步!鏈接:https://www.cnblogs.com/jozochen/p/8541714.html一、問(wèn)題復(fù)現(xiàn)穩(wěn)定復(fù)現(xiàn)問(wèn)題才能正確的對(duì)問(wèn)題進(jìn)行定位、解決以及驗(yàn)證。一般來(lái)說(shuō),越容易復(fù)現(xiàn)的問(wèn)...

關(guān)鍵字: 嵌入式開(kāi)發(fā) 函數(shù) 代碼 寄存器
關(guān)閉