Forked repo of Platform Drivers- Analog Devices

Committer:
Janani Sunil
Date:
Mon Nov 22 22:26:51 2021 +0530
Revision:
20:26b1a4570f4b
Parent:
17:af1f2416dd26
The following changes were made:
1.) Modified udelay() function for generating more accurate smaller usec delays
2.) Implemented the irq_enable and irq_disable functions
3.) Removed the confusion b/w application created peripheral object and interrupt specific object
4.) Created PWM extra init structure and added PWM pin as it's member for multiplatform project compatibility
5.) Added a module for timer and its related header file

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mahphalke 17:af1f2416dd26 1 /***************************************************************************//**
mahphalke 17:af1f2416dd26 2 * @file delay.cpp
mahphalke 17:af1f2416dd26 3 * @brief Implementation of Mbed specific delay functionality
mahphalke 17:af1f2416dd26 4 ********************************************************************************
mahphalke 17:af1f2416dd26 5 * Copyright (c) 2019 - 2021 Analog Devices, Inc.
mahphalke 17:af1f2416dd26 6 * All rights reserved.
mahphalke 17:af1f2416dd26 7 *
mahphalke 17:af1f2416dd26 8 * This software is proprietary to Analog Devices, Inc. and its licensors.
mahphalke 17:af1f2416dd26 9 * By using this software you agree to the terms of the associated
mahphalke 17:af1f2416dd26 10 * Analog Devices Software License Agreement.
mahphalke 17:af1f2416dd26 11 *******************************************************************************/
mahphalke 17:af1f2416dd26 12
mahphalke 17:af1f2416dd26 13 /******************************************************************************/
mahphalke 17:af1f2416dd26 14 /***************************** Include Files **********************************/
mahphalke 17:af1f2416dd26 15 /******************************************************************************/
mahphalke 17:af1f2416dd26 16
mahphalke 17:af1f2416dd26 17 #include <mbed.h>
mahphalke 17:af1f2416dd26 18
mahphalke 17:af1f2416dd26 19 // Platform drivers needs to be C-compatible to work with other drivers
mahphalke 17:af1f2416dd26 20 #ifdef __cplusplus
mahphalke 17:af1f2416dd26 21 extern "C"
mahphalke 17:af1f2416dd26 22 {
mahphalke 17:af1f2416dd26 23 #endif // _cplusplus
mahphalke 17:af1f2416dd26 24
mahphalke 17:af1f2416dd26 25 #include "delay.h"
mahphalke 17:af1f2416dd26 26
mahphalke 17:af1f2416dd26 27 /******************************************************************************/
mahphalke 17:af1f2416dd26 28 /********************** Macros and Constants Definitions **********************/
mahphalke 17:af1f2416dd26 29 /******************************************************************************/
mahphalke 17:af1f2416dd26 30
mahphalke 17:af1f2416dd26 31 /******************************************************************************/
mahphalke 17:af1f2416dd26 32 /************************ Functions Definitions *******************************/
mahphalke 17:af1f2416dd26 33 /******************************************************************************/
mahphalke 17:af1f2416dd26 34
mahphalke 17:af1f2416dd26 35 /**
mahphalke 17:af1f2416dd26 36 * @brief Generate microseconds delay.
mahphalke 17:af1f2416dd26 37 * @param usecs - Delay in microseconds.
mahphalke 17:af1f2416dd26 38 * @return None.
mahphalke 17:af1f2416dd26 39 */
mahphalke 17:af1f2416dd26 40 void udelay(uint32_t usecs)
mahphalke 17:af1f2416dd26 41 {
Janani Sunil 20:26b1a4570f4b 42 /* wait_ns is more time efficient function compared to wait_us
Janani Sunil 20:26b1a4570f4b 43 * Note: For higher values of delay (more than few msec), it is better to use
Janani Sunil 20:26b1a4570f4b 44 * mdelay() function as no error/limit checking is done in this function */
Janani Sunil 20:26b1a4570f4b 45 wait_ns(usecs * 1000);
mahphalke 17:af1f2416dd26 46 }
mahphalke 17:af1f2416dd26 47
mahphalke 17:af1f2416dd26 48 /**
mahphalke 17:af1f2416dd26 49 * @brief Generate miliseconds delay.
mahphalke 17:af1f2416dd26 50 * @param msecs - Delay in miliseconds.
mahphalke 17:af1f2416dd26 51 * @return None.
mahphalke 17:af1f2416dd26 52 */
mahphalke 17:af1f2416dd26 53 void mdelay(uint32_t msecs)
mahphalke 17:af1f2416dd26 54 {
mahphalke 17:af1f2416dd26 55 if (msecs) {
Janani Sunil 20:26b1a4570f4b 56 thread_sleep_for(msecs);
mahphalke 17:af1f2416dd26 57 }
mahphalke 17:af1f2416dd26 58 }
mahphalke 17:af1f2416dd26 59
mahphalke 17:af1f2416dd26 60 #ifdef __cplusplus // Closing extern c
mahphalke 17:af1f2416dd26 61 }
mahphalke 17:af1f2416dd26 62 #endif // _cplusplus