MATSU-bed(LPC1549)でPWMを4つ以上出すプログラム
Dependents: servo_controller_1549
pwm_all_api.h@4:49ee58dc8e4d, 2018-02-17 (annotated)
- Committer:
- hardtail
- Date:
- Sat Feb 17 07:23:48 2018 +0000
- Revision:
- 4:49ee58dc8e4d
- Parent:
- 2:322ad3eef278
- Child:
- 5:88243d59b4df
??????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hardtail | 0:64b18a3829f1 | 1 | /* mbed Microcontroller Library |
hardtail | 0:64b18a3829f1 | 2 | * Copyright (c) 2006-2013 ARM Limited |
hardtail | 0:64b18a3829f1 | 3 | * |
hardtail | 0:64b18a3829f1 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
hardtail | 0:64b18a3829f1 | 5 | * you may not use this file except in compliance with the License. |
hardtail | 0:64b18a3829f1 | 6 | * You may obtain a copy of the License at |
hardtail | 0:64b18a3829f1 | 7 | * |
hardtail | 0:64b18a3829f1 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
hardtail | 0:64b18a3829f1 | 9 | * |
hardtail | 0:64b18a3829f1 | 10 | * Unless required by applicable law or agreed to in writing, software |
hardtail | 0:64b18a3829f1 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
hardtail | 0:64b18a3829f1 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
hardtail | 0:64b18a3829f1 | 13 | * See the License for the specific language governing permissions and |
hardtail | 0:64b18a3829f1 | 14 | * limitations under the License. |
hardtail | 0:64b18a3829f1 | 15 | */ |
hardtail | 0:64b18a3829f1 | 16 | #ifndef MBED_PWM_ALL_API_H |
hardtail | 0:64b18a3829f1 | 17 | #define MBED_PWM_ALL_API_H |
hardtail | 0:64b18a3829f1 | 18 | |
hardtail | 0:64b18a3829f1 | 19 | #include "device.h" |
hardtail | 0:64b18a3829f1 | 20 | |
hardtail | 0:64b18a3829f1 | 21 | |
hardtail | 4:49ee58dc8e4d | 22 | |
hardtail | 0:64b18a3829f1 | 23 | #ifdef __cplusplus |
hardtail | 0:64b18a3829f1 | 24 | extern "C" { |
hardtail | 0:64b18a3829f1 | 25 | #endif |
hardtail | 0:64b18a3829f1 | 26 | |
hardtail | 4:49ee58dc8e4d | 27 | struct pwmout_sct { |
hardtail | 4:49ee58dc8e4d | 28 | LPC_SCT0_Type* pwm; |
hardtail | 4:49ee58dc8e4d | 29 | uint32_t pwm_ch; |
hardtail | 4:49ee58dc8e4d | 30 | uint32_t out_ch; |
hardtail | 4:49ee58dc8e4d | 31 | uint32_t pin; |
hardtail | 4:49ee58dc8e4d | 32 | uint32_t match; |
hardtail | 4:49ee58dc8e4d | 33 | }; |
hardtail | 4:49ee58dc8e4d | 34 | |
hardtail | 4:49ee58dc8e4d | 35 | /** Pwmout hal structure. pwmout_s is declared in the target's hal |
hardtail | 4:49ee58dc8e4d | 36 | */ |
hardtail | 4:49ee58dc8e4d | 37 | typedef struct pwmout_sct pwmout_all_t; |
hardtail | 4:49ee58dc8e4d | 38 | |
hardtail | 4:49ee58dc8e4d | 39 | /** |
hardtail | 4:49ee58dc8e4d | 40 | * \defgroup hal_pwmout Pwmout hal functions |
hardtail | 4:49ee58dc8e4d | 41 | * @{ |
hardtail | 4:49ee58dc8e4d | 42 | */ |
hardtail | 0:64b18a3829f1 | 43 | |
hardtail | 4:49ee58dc8e4d | 44 | /** Initialize the pwm out peripheral and configure the pin |
hardtail | 4:49ee58dc8e4d | 45 | * |
hardtail | 4:49ee58dc8e4d | 46 | * @param obj The pwmout object to initialize |
hardtail | 4:49ee58dc8e4d | 47 | * @param pin The pwmout pin to initialize |
hardtail | 4:49ee58dc8e4d | 48 | */ |
hardtail | 4:49ee58dc8e4d | 49 | void pwmout_all_init(pwmout_all_t *obj, PinName pin); |
hardtail | 4:49ee58dc8e4d | 50 | |
hardtail | 4:49ee58dc8e4d | 51 | /** Deinitialize the pwmout object |
hardtail | 4:49ee58dc8e4d | 52 | * |
hardtail | 4:49ee58dc8e4d | 53 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 54 | */ |
hardtail | 4:49ee58dc8e4d | 55 | void pwmout_all_free(pwmout_all_t *obj); |
hardtail | 0:64b18a3829f1 | 56 | |
hardtail | 4:49ee58dc8e4d | 57 | /** Set the output duty-cycle in range <0.0f, 1.0f> |
hardtail | 4:49ee58dc8e4d | 58 | * |
hardtail | 4:49ee58dc8e4d | 59 | * Value 0.0f represents 0 percentage, 1.0f represents 100 percent. |
hardtail | 4:49ee58dc8e4d | 60 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 61 | * @param percent The floating-point percentage number |
hardtail | 4:49ee58dc8e4d | 62 | */ |
hardtail | 4:49ee58dc8e4d | 63 | void pwmout_all_write(pwmout_all_t *obj, float percent); |
hardtail | 4:49ee58dc8e4d | 64 | |
hardtail | 4:49ee58dc8e4d | 65 | /** Read the current float-point output duty-cycle |
hardtail | 4:49ee58dc8e4d | 66 | * |
hardtail | 4:49ee58dc8e4d | 67 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 68 | * @return A floating-point output duty-cycle |
hardtail | 4:49ee58dc8e4d | 69 | */ |
hardtail | 4:49ee58dc8e4d | 70 | float pwmout_all_read(pwmout_all_t *obj); |
hardtail | 0:64b18a3829f1 | 71 | |
hardtail | 4:49ee58dc8e4d | 72 | /** Set the PWM period specified in seconds, keeping the duty cycle the same |
hardtail | 4:49ee58dc8e4d | 73 | * |
hardtail | 4:49ee58dc8e4d | 74 | * Periods smaller than microseconds (the lowest resolution) are set to zero. |
hardtail | 4:49ee58dc8e4d | 75 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 76 | * @param seconds The floating-point seconds period |
hardtail | 4:49ee58dc8e4d | 77 | */ |
hardtail | 4:49ee58dc8e4d | 78 | void pwmout_all_period(pwmout_all_t *obj, float seconds); |
hardtail | 4:49ee58dc8e4d | 79 | |
hardtail | 4:49ee58dc8e4d | 80 | /** Set the PWM period specified in miliseconds, keeping the duty cycle the same |
hardtail | 4:49ee58dc8e4d | 81 | * |
hardtail | 4:49ee58dc8e4d | 82 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 83 | * @param ms The milisecond period |
hardtail | 4:49ee58dc8e4d | 84 | */ |
hardtail | 4:49ee58dc8e4d | 85 | void pwmout_all_period_ms(pwmout_all_t *obj, int ms); |
hardtail | 4:49ee58dc8e4d | 86 | |
hardtail | 4:49ee58dc8e4d | 87 | /** Set the PWM period specified in microseconds, keeping the duty cycle the same |
hardtail | 4:49ee58dc8e4d | 88 | * |
hardtail | 4:49ee58dc8e4d | 89 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 90 | * @param us The microsecond period |
hardtail | 4:49ee58dc8e4d | 91 | */ |
hardtail | 4:49ee58dc8e4d | 92 | void pwmout_all_period_us(pwmout_all_t *obj, int us); |
hardtail | 0:64b18a3829f1 | 93 | |
hardtail | 4:49ee58dc8e4d | 94 | /** Set the PWM pulsewidth specified in seconds, keeping the period the same. |
hardtail | 4:49ee58dc8e4d | 95 | * |
hardtail | 4:49ee58dc8e4d | 96 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 97 | * @param seconds The floating-point pulsewidth in seconds |
hardtail | 4:49ee58dc8e4d | 98 | */ |
hardtail | 4:49ee58dc8e4d | 99 | void pwmout_all_pulsewidth(pwmout_all_t *obj, float seconds); |
hardtail | 4:49ee58dc8e4d | 100 | |
hardtail | 4:49ee58dc8e4d | 101 | /** Set the PWM pulsewidth specified in miliseconds, keeping the period the same. |
hardtail | 4:49ee58dc8e4d | 102 | * |
hardtail | 4:49ee58dc8e4d | 103 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 104 | * @param ms The floating-point pulsewidth in miliseconds |
hardtail | 4:49ee58dc8e4d | 105 | */ |
hardtail | 4:49ee58dc8e4d | 106 | void pwmout_all_pulsewidth_ms(pwmout_all_t *obj, int ms); |
hardtail | 4:49ee58dc8e4d | 107 | |
hardtail | 4:49ee58dc8e4d | 108 | /** Set the PWM pulsewidth specified in microseconds, keeping the period the same. |
hardtail | 4:49ee58dc8e4d | 109 | * |
hardtail | 4:49ee58dc8e4d | 110 | * @param obj The pwmout object |
hardtail | 4:49ee58dc8e4d | 111 | * @param us The floating-point pulsewidth in microseconds |
hardtail | 4:49ee58dc8e4d | 112 | */ |
hardtail | 4:49ee58dc8e4d | 113 | void pwmout_all_pulsewidth_us(pwmout_all_t *obj, int us); |
hardtail | 4:49ee58dc8e4d | 114 | |
hardtail | 4:49ee58dc8e4d | 115 | /**@}*/ |
hardtail | 0:64b18a3829f1 | 116 | |
hardtail | 0:64b18a3829f1 | 117 | #ifdef __cplusplus |
hardtail | 0:64b18a3829f1 | 118 | } |
hardtail | 0:64b18a3829f1 | 119 | #endif |
hardtail | 0:64b18a3829f1 | 120 | |
hardtail | 0:64b18a3829f1 | 121 | |
hardtail | 0:64b18a3829f1 | 122 | #endif |