MCU driver/HAL for the Picocell Gateway concentrator board. The firmware implements either a USB CDC protocol or a UART protocol to bridge commands coming from host to the SX1308 SPI interface.
src/mbed-dev/hal/pwmout_api.h@0:c76361bd82e8, 2018-04-11 (annotated)
- Committer:
- dgabino
- Date:
- Wed Apr 11 14:42:47 2018 +0000
- Revision:
- 0:c76361bd82e8
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dgabino | 0:c76361bd82e8 | 1 | /* mbed Microcontroller Library |
dgabino | 0:c76361bd82e8 | 2 | * Copyright (c) 2006-2013 ARM Limited |
dgabino | 0:c76361bd82e8 | 3 | * |
dgabino | 0:c76361bd82e8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
dgabino | 0:c76361bd82e8 | 5 | * you may not use this file except in compliance with the License. |
dgabino | 0:c76361bd82e8 | 6 | * You may obtain a copy of the License at |
dgabino | 0:c76361bd82e8 | 7 | * |
dgabino | 0:c76361bd82e8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
dgabino | 0:c76361bd82e8 | 9 | * |
dgabino | 0:c76361bd82e8 | 10 | * Unless required by applicable law or agreed to in writing, software |
dgabino | 0:c76361bd82e8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
dgabino | 0:c76361bd82e8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
dgabino | 0:c76361bd82e8 | 13 | * See the License for the specific language governing permissions and |
dgabino | 0:c76361bd82e8 | 14 | * limitations under the License. |
dgabino | 0:c76361bd82e8 | 15 | */ |
dgabino | 0:c76361bd82e8 | 16 | #ifndef MBED_PWMOUT_API_H |
dgabino | 0:c76361bd82e8 | 17 | #define MBED_PWMOUT_API_H |
dgabino | 0:c76361bd82e8 | 18 | |
dgabino | 0:c76361bd82e8 | 19 | #include "device.h" |
dgabino | 0:c76361bd82e8 | 20 | |
dgabino | 0:c76361bd82e8 | 21 | #if DEVICE_PWMOUT |
dgabino | 0:c76361bd82e8 | 22 | |
dgabino | 0:c76361bd82e8 | 23 | #ifdef __cplusplus |
dgabino | 0:c76361bd82e8 | 24 | extern "C" { |
dgabino | 0:c76361bd82e8 | 25 | #endif |
dgabino | 0:c76361bd82e8 | 26 | |
dgabino | 0:c76361bd82e8 | 27 | /** Pwmout hal structure. pwmout_s is declared in the target's hal |
dgabino | 0:c76361bd82e8 | 28 | */ |
dgabino | 0:c76361bd82e8 | 29 | typedef struct pwmout_s pwmout_t; |
dgabino | 0:c76361bd82e8 | 30 | |
dgabino | 0:c76361bd82e8 | 31 | /** |
dgabino | 0:c76361bd82e8 | 32 | * \defgroup hal_pwmout Pwmout hal functions |
dgabino | 0:c76361bd82e8 | 33 | * @{ |
dgabino | 0:c76361bd82e8 | 34 | */ |
dgabino | 0:c76361bd82e8 | 35 | |
dgabino | 0:c76361bd82e8 | 36 | /** Initialize the pwm out peripheral and configure the pin |
dgabino | 0:c76361bd82e8 | 37 | * |
dgabino | 0:c76361bd82e8 | 38 | * @param obj The pwmout object to initialize |
dgabino | 0:c76361bd82e8 | 39 | * @param pin The pwmout pin to initialize |
dgabino | 0:c76361bd82e8 | 40 | */ |
dgabino | 0:c76361bd82e8 | 41 | void pwmout_init(pwmout_t *obj, PinName pin); |
dgabino | 0:c76361bd82e8 | 42 | |
dgabino | 0:c76361bd82e8 | 43 | /** Deinitialize the pwmout object |
dgabino | 0:c76361bd82e8 | 44 | * |
dgabino | 0:c76361bd82e8 | 45 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 46 | */ |
dgabino | 0:c76361bd82e8 | 47 | void pwmout_free(pwmout_t *obj); |
dgabino | 0:c76361bd82e8 | 48 | |
dgabino | 0:c76361bd82e8 | 49 | /** Set the output duty-cycle in range <0.0f, 1.0f> |
dgabino | 0:c76361bd82e8 | 50 | * |
dgabino | 0:c76361bd82e8 | 51 | * Value 0.0f represents 0 percentage, 1.0f represents 100 percent. |
dgabino | 0:c76361bd82e8 | 52 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 53 | * @param percent The floating-point percentage number |
dgabino | 0:c76361bd82e8 | 54 | */ |
dgabino | 0:c76361bd82e8 | 55 | void pwmout_write(pwmout_t *obj, float percent); |
dgabino | 0:c76361bd82e8 | 56 | |
dgabino | 0:c76361bd82e8 | 57 | /** Read the current float-point output duty-cycle |
dgabino | 0:c76361bd82e8 | 58 | * |
dgabino | 0:c76361bd82e8 | 59 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 60 | * @return A floating-point output duty-cycle |
dgabino | 0:c76361bd82e8 | 61 | */ |
dgabino | 0:c76361bd82e8 | 62 | float pwmout_read(pwmout_t *obj); |
dgabino | 0:c76361bd82e8 | 63 | |
dgabino | 0:c76361bd82e8 | 64 | /** Set the PWM period specified in seconds, keeping the duty cycle the same |
dgabino | 0:c76361bd82e8 | 65 | * |
dgabino | 0:c76361bd82e8 | 66 | * Periods smaller than microseconds (the lowest resolution) are set to zero. |
dgabino | 0:c76361bd82e8 | 67 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 68 | * @param seconds The floating-point seconds period |
dgabino | 0:c76361bd82e8 | 69 | */ |
dgabino | 0:c76361bd82e8 | 70 | void pwmout_period(pwmout_t *obj, float seconds); |
dgabino | 0:c76361bd82e8 | 71 | |
dgabino | 0:c76361bd82e8 | 72 | /** Set the PWM period specified in miliseconds, keeping the duty cycle the same |
dgabino | 0:c76361bd82e8 | 73 | * |
dgabino | 0:c76361bd82e8 | 74 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 75 | * @param ms The milisecond period |
dgabino | 0:c76361bd82e8 | 76 | */ |
dgabino | 0:c76361bd82e8 | 77 | void pwmout_period_ms(pwmout_t *obj, int ms); |
dgabino | 0:c76361bd82e8 | 78 | |
dgabino | 0:c76361bd82e8 | 79 | /** Set the PWM period specified in microseconds, keeping the duty cycle the same |
dgabino | 0:c76361bd82e8 | 80 | * |
dgabino | 0:c76361bd82e8 | 81 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 82 | * @param us The microsecond period |
dgabino | 0:c76361bd82e8 | 83 | */ |
dgabino | 0:c76361bd82e8 | 84 | void pwmout_period_us(pwmout_t *obj, int us); |
dgabino | 0:c76361bd82e8 | 85 | |
dgabino | 0:c76361bd82e8 | 86 | /** Set the PWM pulsewidth specified in seconds, keeping the period the same. |
dgabino | 0:c76361bd82e8 | 87 | * |
dgabino | 0:c76361bd82e8 | 88 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 89 | * @param seconds The floating-point pulsewidth in seconds |
dgabino | 0:c76361bd82e8 | 90 | */ |
dgabino | 0:c76361bd82e8 | 91 | void pwmout_pulsewidth(pwmout_t *obj, float seconds); |
dgabino | 0:c76361bd82e8 | 92 | |
dgabino | 0:c76361bd82e8 | 93 | /** Set the PWM pulsewidth specified in miliseconds, keeping the period the same. |
dgabino | 0:c76361bd82e8 | 94 | * |
dgabino | 0:c76361bd82e8 | 95 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 96 | * @param ms The floating-point pulsewidth in miliseconds |
dgabino | 0:c76361bd82e8 | 97 | */ |
dgabino | 0:c76361bd82e8 | 98 | void pwmout_pulsewidth_ms(pwmout_t *obj, int ms); |
dgabino | 0:c76361bd82e8 | 99 | |
dgabino | 0:c76361bd82e8 | 100 | /** Set the PWM pulsewidth specified in microseconds, keeping the period the same. |
dgabino | 0:c76361bd82e8 | 101 | * |
dgabino | 0:c76361bd82e8 | 102 | * @param obj The pwmout object |
dgabino | 0:c76361bd82e8 | 103 | * @param us The floating-point pulsewidth in microseconds |
dgabino | 0:c76361bd82e8 | 104 | */ |
dgabino | 0:c76361bd82e8 | 105 | void pwmout_pulsewidth_us(pwmout_t *obj, int us); |
dgabino | 0:c76361bd82e8 | 106 | |
dgabino | 0:c76361bd82e8 | 107 | /**@}*/ |
dgabino | 0:c76361bd82e8 | 108 | |
dgabino | 0:c76361bd82e8 | 109 | #ifdef __cplusplus |
dgabino | 0:c76361bd82e8 | 110 | } |
dgabino | 0:c76361bd82e8 | 111 | #endif |
dgabino | 0:c76361bd82e8 | 112 | |
dgabino | 0:c76361bd82e8 | 113 | #endif |
dgabino | 0:c76361bd82e8 | 114 | |
dgabino | 0:c76361bd82e8 | 115 | #endif |