File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222#include "drivers/sf32lb/i2c_hal_definitions.h"
2323#include "drivers/sf32lb/pwm_hal_definitions.h"
2424#include "board/board_sf32lb.h"
25-
25+ #include "drivers/ioexp.h"
26+ #include "drivers/vibe.h"
2627
2728
2829#define USING_UART1
@@ -377,6 +378,17 @@ void board_early_init(void) {
377378
378379}
379380
381+ #include "bf0_hal.h"
380382void board_init (void ) {
381-
383+ i2c_init (& I2C1_BUS );
384+ i2c_init (& I2C2_BUS );
385+ i2c_init (& I2C3_BUS );
386+ i2c_init (& I2C_COMM_BUS );
387+
388+ PBL_LOG (LOG_LEVEL_DEBUG , "enr1:0x%08lx" , * (uint32_t * )& hwp_hpsys_rcc -> ENR1 );
389+ PBL_LOG (LOG_LEVEL_DEBUG , "enr2:0x%08lx" , * (uint32_t * )& hwp_hpsys_rcc -> ENR2 );
390+ //ioexp_init();
391+ //vibe_init();
392+ //PBL_LOG(LOG_LEVEL_DEBUG, "enr1:0x%08lx", *(uint32_t *)&hwp_hpsys_rcc->ENR1);
393+ //PBL_LOG(LOG_LEVEL_DEBUG, "enr2:0x%08lx", *(uint32_t *)&hwp_hpsys_rcc->ENR2);
382394}
Original file line number Diff line number Diff line change 2626static bool prv_read_register (uint8_t register_address , uint8_t * result ) {
2727 i2c_use (I2C_AW9527 );
2828 bool rv = i2c_read_register (I2C_AW9527 , register_address , result );
29- i2c_release (I2C_AW86225 );
29+ i2c_release (I2C_AW9527 );
3030 return rv ;
3131}
3232
@@ -65,5 +65,23 @@ void ioexp_led_ctrl(uint8_t percent) {
6565
6666/*channel ctrl*/
6767void ioexp_pin_set (IOEXP_CHANNEL_T channel , IOEXP_STATE_T state ) {
68-
68+ if (channel >= IOEXP_CH10 ) {
69+ uint8_t p1_value ;
70+ prv_read_register (0x03 , & p1_value );
71+ if (state == IOEXP_HIGH ) {
72+ p1_value |= (1 <<channel );
73+ } else {
74+ p1_value &= ~(1 <<channel );
75+ }
76+ prv_write_register (0x03 , p1_value );
77+ } else {
78+ uint8_t p0_value ;
79+ prv_read_register (0x02 , & p0_value );
80+ if (state == IOEXP_HIGH ) {
81+ p0_value |= (1 <<channel );
82+ } else {
83+ p0_value &= ~(1 <<channel );
84+ }
85+ prv_write_register (0x02 , p0_value );
86+ }
6987}
Original file line number Diff line number Diff line change @@ -212,6 +212,8 @@ elif bld.is_obelix():
212212 'driver_flash' ,
213213 # 'driver_accessory',
214214 'driver_gpio_defaults' ,
215+ 'driver_ioe' ,
216+ 'driver_motor' ,
215217 ],
216218 )
217219
@@ -1587,7 +1589,7 @@ if mcu_family == 'SF32LB':
15871589 #'display/sharp_ls013b7dh01/sharp_ls013b7dh01_nrf5.c',
15881590 'sf32lb/stubs/accel.c' ,
15891591 'sf32lb/stubs/ambient_light.c' ,
1590- 'sf32lb/stubs/vibe.c' ,
1592+ # 'sf32lb/stubs/vibe.c',
15911593 'sf32lb/stubs/otp.c' ,
15921594 'sf32lb/stubs/mcu.c' ,
15931595 'sf32lb/stubs/backlight.c' ,
You can’t perform that action at this time.
0 commit comments