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

當前位置:首頁 > 單片機 > 單片機
[導讀] 1,開發(fā)環(huán)境 1,適用芯片:STM32F4全部芯片 2,固件庫:STM32F4xx_DSP_StdPeriph_Lib_V1.8.0 3,IDE:MDK5172,驅動源碼 Delay.h文件/*************************************************************

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

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

2,固件庫:STM32F4xx_DSP_StdPeriph_Lib_V1.8.0

3,IDE:MDK517


2,驅動源碼

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--;

}

}



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

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

關鍵字: 函數 數據處理

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

關鍵字: START 亞馬遜 PS 函數

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

關鍵字: 函數 Panda

深圳2024年8月15日 /美通社/ -- 近日,知名量化交易平臺水母量化正式推出了突破性的輪動交易策略回測功能,目前已進入公測階段。該功能實現了從策略設計、歷史回測到實盤自動交易一體化流程,幫用戶解決了策略驗證難、交易...

關鍵字: 編程 仿真 函數 開源

Python由荷蘭數學和計算機科學研究學會的吉多·范羅蘇姆于1990年代初設計,作為一門叫做ABC語言的替代品。 Python提供了高效的高級數據結構,還能簡單有效地面向對象編程。

關鍵字: python 函數 對象編程

測試數據綜合分析的絕佳工具,深受工程師和研究員歡迎

關鍵字: 后處理分析軟件 向導 函數

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

關鍵字: 進程地址 局部變量 函數

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

關鍵字: 騰訊 函數 進程 AI

程序接口是操作系統(tǒng)為用戶提供的兩類接口之一,編程人員在程序中通過程序接口來請求操作系統(tǒng)提供服務。面向過程語言最基本的單元是過程和函數。

關鍵字: 程序接口 過程 函數

星標「嵌入式大雜燴」,一起進步!鏈接:https://www.cnblogs.com/jozochen/p/8541714.html一、問題復現穩(wěn)定復現問題才能正確的對問題進行定位、解決以及驗證。一般來說,越容易復現的問...

關鍵字: 嵌入式開發(fā) 函數 代碼 寄存器
關閉