PWM Driver

The PWM driver is used for configuring pulse-width modulation (PWM) on an end device’s pin.

Data Structures

ATMO_PWM_Peripheral_t

PWM peripheral configuration.

Member Name Type Description
pwmFreq_Hz uint32_t Frequency in Hz

ATMO_PWM_Channel_t

PWM channel specific (advanced) configuration.

Member Name Type Description
dutyCycle uint8_t Duty cycle in whole percent from 0 - 100
level ATMO_PWM_OutputLevel_t PWM output level

Enumerations

enum ATMO_PWM_Status_t

PWM driver return enumerations.

Name Value Description
ATMO_PWM_Status_Success 0x00u Operation was successful
ATMO_PWM_Status_Fail 0x01u Operation failed
ATMO_PWM_Status_Initialized 0x02u Peripheral already initialized
ATMO_PWM_Status_Invalid 0x03u Invalid operation
ATMO_PWM_Status_NotSupported 0x04u Feature not supported by platform
ATMO_PWM_Status_Unknown 0x05u Some other status not defined
ATMO_PWM_Status_Busy 0x20u Conversion in progress
ATMO_PWM_Status_Timeout 0x21u Conversion timed out

enum ATMO_PWM_OutputLevel_t

PWM output level.

Name Value
ATMO_PWM_OutputLevel_Disabled 0x00u
ATMO_PWM_OutputLevel_ActiveLow 0x01u
ATMO_PWM_OutputLevel_ActiveHigh 0x02u

Functions

ATMO_Status_t ATMO_PWM_AddDriverInstance(const ATMO_PWM_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

Register low level driver instance with main PWM driver

Parameter Direction Type
instanceNumber N/A ATMO_DriverInstanceHandle_t *
driverInstanceData N/A ATMO_DriverInstanceData_t *
driverInstance N/A const ATMO_PWM_DriverInstance_t *
Return Type
ATMO_Status_t

ATMO_PWM_Status_t ATMO_PWM_Init(ATMO_DriverInstanceHandle_t instance)

This routine initializes data structures for the PWM Driver

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_SetConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_PWM_Peripheral_t *config)

This routine configures the specified PWM peripheral instance.

Parameter Direction Type
config N/A ATMO_PWM_Peripheral_t *
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_GetConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_PWM_Peripheral_t *config)

This routine retrieves the current configuration of the specified PWM peripheral instance.

Parameter Direction Type
config N/A ATMO_PWM_Peripheral_t *
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_SetPinConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_PWM_Channel_t *config)

This routine configures the specified PWM peripheral pin.

Parameter Direction Type
config N/A ATMO_PWM_Channel_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_GetPinConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_PWM_Channel_t *config)

This routine retrieves the current configuration of the specified PWM peripheral pin.

Parameter Direction Type
config N/A ATMO_PWM_Channel_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_DeInit(ATMO_DriverInstanceHandle_t instance)

This routine de-initializes the specified PWM peripheral instance.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_SetFrequency(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, uint32_t freqHz)

This routine sets the frequency for the specified PWM peripheral.

Parameter Direction Type
freqHz N/A uint32_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_SetDutyCycle(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, uint8_t dutyCycle)

This routine sets the duty cycle for the specified PWM peripheral channel.

Parameter Direction Type
dutyCycle N/A uint8_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_Enable(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin)

This routine enables the specified PWM pin.

Parameter Direction Type
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t

ATMO_PWM_Status_t ATMO_PWM_Disable(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin)

This routine disables the specified PWM pin.

Parameter Direction Type
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_PWM_Status_t