34static volatile uint32_t *initializedChannel[
NUM_PWM] = {
39 if (pwm < 0 || pwm >=
NUM_PWM) {
40 pynq_error(
"pwm_initialized: invalid pwm=%d, must be 0..%d-1\n", pwm,
43 if (initializedChannel[pwm] == NULL) {
50 if (pwm < 0 || pwm >=
NUM_PWM) {
51 pynq_error(
"pwm_initialized: invalid pwm=%d, must be 0..%d-1\n", pwm,
54 if (initializedChannel[pwm] == NULL) {
55 pynq_error(
"pwm_initialized: channel of pwm %d has not been initialized\n",
61void pwm_init(
const int pwm,
const uint32_t period) {
62 if (pwm < 0 || pwm >=
NUM_PWM) {
65 uint32_t channelAddr = axi_pwm_base + (pwm * 0x10000);
66 initializedChannel[pwm] =
arm_shared_init(&channels[pwm], channelAddr, 512);
75 initializedChannel[pwm] = NULL;
void arm_shared_close(arm_shared *handle)
void * arm_shared_init(arm_shared *handle, const uint32_t address, const uint32_t length)
void pwm_init(const int pwm, const uint32_t period)
Initializes the PWM channel with the specified period.
uint32_t pwm_get_steps(const int pwm)
Get the amount of steps a certain channel has taken so far.
void pwm_set_steps(const int pwm, const uint32_t steps)
Generates a steps steps on the PWM channel.
void pwm_destroy(const int pwm)
Removes the instantiated shared memory system of the PWM channel.
uint32_t pwm_get_duty_cycle(const int pwm)
Gets the duty cycle of the specified PWM channel.
void pwm_set_duty_cycle(const int pwm, const uint32_t duty)
Sets the duty cycle for the specified PWM channel.
bool pwm_initialized(const int pwm)
Checks if the channel index is initialized.
void pwm_set_period(const int pwm, const uint32_t period)
Sets the period for the specified PWM channel.
uint32_t pwm_get_period(const int pwm)
Returns the period of a certain PWM channel.
bool check_initialized_pwm(const int pwm)