diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c new file mode 100644 index 000000000..2e6a3f4d1 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright 2017-2018, 2020 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * | ||
6 | * SPDX-License-Identifier: BSD-3-Clause | ||
7 | */ | ||
8 | |||
9 | #include "fsl_common.h" | ||
10 | #include "fsl_sccb.h" | ||
11 | |||
12 | /******************************************************************************* | ||
13 | * Definitions | ||
14 | ******************************************************************************/ | ||
15 | |||
16 | /******************************************************************************* | ||
17 | * Code | ||
18 | ******************************************************************************/ | ||
19 | |||
20 | status_t SCCB_WriteReg( | ||
21 | uint8_t i2cAddr, sccb_reg_addr_t addrType, uint32_t reg, uint8_t value, sccb_i2c_send_func_t i2cSendFunc) | ||
22 | { | ||
23 | return i2cSendFunc(i2cAddr, reg, addrType, &value, 1); | ||
24 | } | ||
25 | |||
26 | status_t SCCB_WriteMultiRegs(uint8_t i2cAddr, | ||
27 | sccb_reg_addr_t addrType, | ||
28 | uint32_t startReg, | ||
29 | const uint8_t *value, | ||
30 | uint32_t len, | ||
31 | sccb_i2c_send_func_t i2cSendFunc) | ||
32 | { | ||
33 | return i2cSendFunc(i2cAddr, startReg, addrType, value, len); | ||
34 | } | ||
35 | |||
36 | status_t SCCB_ReadReg( | ||
37 | uint8_t i2cAddr, sccb_reg_addr_t addrType, uint32_t reg, uint8_t *value, sccb_i2c_receive_func_t i2cReceiveFunc) | ||
38 | { | ||
39 | return i2cReceiveFunc(i2cAddr, reg, addrType, value, 1); | ||
40 | } | ||
41 | |||
42 | status_t SCCB_ModifyReg(uint8_t i2cAddr, | ||
43 | sccb_reg_addr_t addrType, | ||
44 | uint32_t reg, | ||
45 | uint8_t clrMask, | ||
46 | uint8_t value, | ||
47 | sccb_i2c_receive_func_t i2cReceiveFunc, | ||
48 | sccb_i2c_send_func_t i2cSendFunc) | ||
49 | { | ||
50 | status_t status; | ||
51 | uint8_t regVal = 0U; | ||
52 | |||
53 | status = SCCB_ReadReg(i2cAddr, addrType, reg, ®Val, i2cReceiveFunc); | ||
54 | |||
55 | if (kStatus_Success != status) | ||
56 | { | ||
57 | return status; | ||
58 | } | ||
59 | |||
60 | regVal = (uint8_t)(regVal & ~((uint32_t)clrMask)) | (value & clrMask); | ||
61 | |||
62 | return SCCB_WriteReg(i2cAddr, addrType, reg, regVal, i2cSendFunc); | ||
63 | } | ||