
#ifndef PMOD_DHB1_L_H
#define PMOD_DHB1_L_H


/****************** Include Files ********************/
#include "xil_types.h"
#include "xstatus.h"

#define PMOD_DHB1_GPIO_DATA_OFFSET  0
#define PMOD_DHB1_GPIO_TRI_OFFSET   4
#define PMOD_DHB1_GPIO2_DATA_OFFSET 8
#define PMOD_DHB1_GPIO2_TRI_OFFSET  12

#define PMOD_DHB1_PWM_CTRL_REG_OFFSET 0
#define PMOD_DHB1_PWM_STATUS_REG_OFFSET 4
#define PMOD_DHB1_PWM_PERIOD_REG_OFFSET 8
#define PMOD_DHB1_PWM_DUTY_REG_OFFSET 12

#define PMOD_DHB1_MOTOR_FB_CLEAR_REG_OFFSET 0
#define PMOD_DHB1_MOTOR_FB_M1_POS_REG_OFFSET 4
#define PMOD_DHB1_MOTOR_FB_M2_POS_REG_OFFSET 8
#define PMOD_DHB1_MOTOR_FB_POS_DIFF_REG_OFFSET 12
#define PMOD_DHB1_MOTOR_FB_CLOCK_COUNT_REG_OFFSET 16


/**************************** Type Definitions *****************************/
/**
 *
 * Write a value to a PMOD_DHB1 register. A 32 bit write is performed.
 * If the component is implemented in a smaller width, only the least
 * significant data is written.
 *
 * @param   BaseAddress is the base address of the PMOD_DHB1device.
 * @param   RegOffset is the register offset from the base to write to.
 * @param   Data is the data written to the register.
 *
 * @return  None.
 *
 * @note
 * C-style signature:
 * 	void PMOD_DHB1_mWriteReg(u32 BaseAddress, unsigned RegOffset, u32 Data)
 *
 */
#define PMOD_DHB1_mWriteReg(BaseAddress, RegOffset, Data) \
  	Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data))

/**
 *
 * Read a value from a PMOD_DHB1 register. A 32 bit read is performed.
 * If the component is implemented in a smaller width, only the least
 * significant data is read from the register. The most significant data
 * will be read as 0.
 *
 * @param   BaseAddress is the base address of the PMOD_DHB1 device.
 * @param   RegOffset is the register offset from the base to write to.
 *
 * @return  Data is the data from the register.
 *
 * @note
 * C-style signature:
 * 	u32 PMOD_DHB1_mReadReg(u32 BaseAddress, unsigned RegOffset)
 *
 */
#define PMOD_DHB1_mReadReg(BaseAddress, RegOffset) \
    Xil_In32((BaseAddress) + (RegOffset))

/************************** Function Prototypes ****************************/
/**
 *
 * Run a self-test on the driver/device. Note this may be a destructive test if
 * resets of the device are performed.
 *
 * If the hardware system is not built correctly, this function may never
 * return to the caller.
 *
 * @param   baseaddr_p is the base address of the PMOD_DHB1 instance to be worked on.
 *
 * @return
 *
 *    - XST_SUCCESS   if all self-test code passed
 *    - XST_FAILURE   if any self-test code failed
 *
 * @note    Caching must be turned off for this function to work.
 * @note    Self test may fail if data memory and device are not on the same bus.
 *
 */
XStatus PMOD_DHB1_Reg_SelfTest(void * baseaddr_p);

#endif // PMOD_DHB1_L_H
