Hi all,
In next patch I will apply changes for working code as well as will
add licence information to pwm.c file. Right now I added URL to
commit. Should I go ahead for further changes ?
Thanks,
Punit Vara
On Wed, Jun 22, 2016 at 12:26 PM, Punit Vara wrote:
> This patch perform following things:
> - adds original BBBIO PWM code as it is.
> - not added to Makefile otherwise it will break build
> - adds required registers
> - adds declarations to BSP_HEADERS
>
> This code is added from
>
> https://github.com/VegetableAvenger/BBBIOlib/blob/master/BBBio_lib/BBBiolib_PWMSS.c
> ---
> c/src/lib/libbsp/arm/beagle/include/bbb-pwm.h | 46 +++
> c/src/lib/libbsp/arm/beagle/pwm/pwm.c | 407
> ++
> c/src/lib/libcpu/arm/shared/include/am335x.h | 11 +-
> 3 files changed, 463 insertions(+), 1 deletion(-)
> create mode 100644 c/src/lib/libbsp/arm/beagle/include/bbb-pwm.h
> create mode 100644 c/src/lib/libbsp/arm/beagle/pwm/pwm.c
>
> diff --git a/c/src/lib/libbsp/arm/beagle/include/bbb-pwm.h
> b/c/src/lib/libbsp/arm/beagle/include/bbb-pwm.h
> new file mode 100644
> index 000..bd70385
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/beagle/include/bbb-pwm.h
> @@ -0,0 +1,46 @@
> +/**
> + * @file
> + *
> + * @ingroup arm_beagle
> + *
> + * @brief BeagleBone Black BSP definitions.
> + */
> +
> +/**
> + * Copyright (c) 2016 Punit Vara
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#ifndef LIBBSP_ARM_BEAGLE_BBB_PWM_H
> +#define LIBBSP_ARM_BEAGLE_BBB_PWM_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/**
> + * @brief BeagleBone Black PWM functions.
> + */
> +#define BBBIO_PWMSS_COUNT 3
> +#define BBBIO_PWMSS0 0
> +#define BBBIO_PWMSS1 1
> +#define BBBIO_PWMSS2 2
> +
> +/**
> + * @brief BeagleBone Black PWM API.
> + */
> +int BBBIO_PWMSS_Setting(unsigned int PWMID , float HZ ,float dutyA ,float
> dutyB);
> +int BBBIO_PWM_Init();
> +void BBBIO_PWM_Release();
> +int BBBIO_PWMSS_Status(unsigned int PWMID);
> +void BBBIO_ehrPWM_Enable(unsigned int PWMSS_ID);
> +void BBBIO_ehrPWM_Disable(unsigned int PWMSS_ID);
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* LIBBSP_ARM_BEAGLE_BBB_PWM_H */
> diff --git a/c/src/lib/libbsp/arm/beagle/pwm/pwm.c
> b/c/src/lib/libbsp/arm/beagle/pwm/pwm.c
> new file mode 100644
> index 000..f65ff89
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/beagle/pwm/pwm.c
> @@ -0,0 +1,407 @@
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include "BBBiolib.h"
> +/*---*/
> +/*
> + * PWMSS Registers
> + *
> + * @Source : AM335x Technical Reference Manual ,page 1991
> + * Table 15-5. PWMSS REGISTERS
> + *
> +*/
> +
> +#define PWMSS0_MMAP_ADDR 0x4830
> +#define PWMSS1_MMAP_ADDR 0x48302000
> +#define PWMSS2_MMAP_ADDR 0x48304000
> +#define PWMSS_MMAP_LEN 0x1000
> +
> +#define PWMSS_IDVER0x0
> +#define PWMSS_SYSCONFIG0x4
> +#define PWMSS_CLKCONFIG0x8
> +#define PWMSS_CLKSTATUS0xC
> +
> +/* EPWM Registers
> + *
> + * @Source : AM335x Technical Reference Manual ,page 2084
> + * Table 15-58. EPWM REGISTERS
> + *
> +*/
> +#define EPWM_TBCTL 0x0
> +#define EPWM_TBSTS 0x2
> +#define EPWM_TBPHSHR 0x4
> +#define EPWM_TBPHS 0x6
> +#define EPWM_TBCNT 0x8
> +#define EPWM_TBPRD 0xA
> +#define EPWM_CMPCTL0xE
> +#define EPWM_CMPAHR0x10
> +#define EPWM_CMPA 0x12
> +#define EPWM_CMPB 0x14
> +#define EPWM_AQCTLA0x16
> +#define EPWM_AQCTLB0x18
> +#define EPWM_AQSFRC0x1A
> +#define EPWM_AQCSFRC 0x1C
> +#define EPWM_DBCTL 0x1E
> +#define EPWM_DBRED 0x20
> +#define EPWM_DBFED 0x22
> +/*---*/
> +extern int memh;
> +extern volatile unsigned int *CM_ptr; /*c ontrol module */
> +volatile unsigned int *cm_per_addr;
> +
> +
> +const unsigned int PWMSS_AddressOffset[]={PWMSS0_MMAP_ADDR,
> + PWMSS1_MMAP_ADDR,
> + PWMSS2_MMAP_ADDR};
> +volatile unsigned int *pwmss_ptr[3] ={NULL, NULL, NULL} ;
> +volatile unsigned int *epwm_ptr[3] ={NULL, NULL, NULL} ;
> +volatile unsigned int *ecap_ptr[3] ={NULL, NULL, NULL} ;
> +volatile unsigned int *eqep_ptr[3] ={NULL, NULL, NULL} ;
> +
> +#define TBCTL_CTRMODE_UP0x0
> +#define TBCTL_CTRMODE_DOWN 0x1
> +#define TBCTL_CTRMODE_UPDOWN0x2
> +#define TBCTL_CTRMODE_FREEZE0x3
> +/*
>