27 lines
890 B
C
27 lines
890 B
C
#include "pixart_pah8001ei.h"
|
|
|
|
#define PAH8001_R_CONFIG 0x06
|
|
#define PAH8001_R_CONFIG_RESET_Pos 7
|
|
#define PAH8001_R_CONFIG_RESET_Msk (1U << PAH8001_R_CONFIG_RESET_Pos)
|
|
#define PAH8001_R_CONFIG_POWERDOWN_Pos 3
|
|
#define PAH8001_R_CONFIG_POWERDOWN_Msk (1U << PAH8001_R_CONFIG_POWERDOWN_Pos)
|
|
|
|
#define PAH8001_ERROR_CHECK(x) \
|
|
if (x != PAH_RET_OK) return PAH_RET_FAIL
|
|
|
|
static pah_ret_t pah8001_reset(pah_t *pah) {
|
|
uint8_t wdata = PAH8001_R_CONFIG_RESET_Msk | 2U;
|
|
PAH8001_ERROR_CHECK(pah->ops.write(pah->pdev, PAH8001_R_CONFIG, &wdata, 0x01));
|
|
|
|
wdata = PAH8001_R_CONFIG_POWERDOWN_Msk | 2U;
|
|
PAH8001_ERROR_CHECK(pah->ops.write(pah->pdev, PAH8001_R_CONFIG, &wdata, 0x01));
|
|
|
|
return PAH_RET_OK;
|
|
}
|
|
|
|
pah_ret_t pah8001_init(pah_t *pah) {
|
|
PAH8001_ERROR_CHECK(pah->ops.init(pah->pdev));
|
|
|
|
PAH8001_ERROR_CHECK(pah8001_reset(pah));
|
|
return PAH_RET_OK;
|
|
} |