Skip to content

Commit

Permalink
Merge pull request #28 from jaenrig-ifx/psoc6_i2c
Browse files Browse the repository at this point in the history
Psoc6 i2c
  • Loading branch information
bargfred authored Jan 30, 2023
2 parents c6dc1ff + cf7f06b commit 5689ec7
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
2 changes: 0 additions & 2 deletions ports/psoc6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingl

# c11 : provides "static_assert" (not available in c99)
# -D_XOPEN_SOURCE=700 : makes sure the setenv/unsetenv headers are included
#CFLAGS = $(INC) -Wall $(CFLAGS_CORTEX_M4) $(COPT) -std=c11 -D_XOPEN_SOURCE=700
CFLAGS = $(INC) -Wall -Werror $(CFLAGS_CORTEX_M4) $(COPT) -std=c11 -D_XOPEN_SOURCE=700 -Wno-error=double-promotion -Wno-error=overflow

#CFLAGS = $(INC) -Wall -Werror -std=c99 $(CFLAGS_CORTEX_M4) $(COPT)
LDFLAGS = -Wl,--cref -Wl,--gc-sections


Expand Down
1 change: 0 additions & 1 deletion ports/psoc6/boards/CY8CPROTO-062-4343W/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ TARGET=APP_CY8CPROTO-062-4343W
#
# If APPNAME / LIBNAME is edited, ensure to update or regenerate launch
# configurations for your IDE.
#APPNAME=mtb
LIBNAME=libmtb

# Name of toolchain to use. Options include:
Expand Down
2 changes: 1 addition & 1 deletion ports/psoc6/modules/machine/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum {ARG_mode, ARG_pull, ARG_value, ARG_drive, ARG_alt};
static const mp_arg_t allowed_args[] = {
{MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
{MP_QSTR_pull, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
{MP_QSTR_valu, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
{MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
{MP_QSTR_drive, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
{MP_QSTR_alt, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = HSIOM_GPIO_FUNC}}, // default value of HSIOM set to GPIO mode of pin.
};
Expand Down
5 changes: 5 additions & 0 deletions ports/psoc6/modules/machine/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
// port-specific includes
#include "modmachine.h"


// cy includes
#include "cyhal.h"


// mpy include


/* Include Pin definitions to make it visible at py side*/
// Generated manually w.r.t cyhal_gpio_psoc6_02_124_bga_t enum for the package present in the CYPROTO-062-4343 target
// TODO: automate this generation using a python script, same as other ports.
Expand Down
6 changes: 0 additions & 6 deletions ports/psoc6/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ int mp_hal_pin_read(mp_hal_pin_obj_t pin) {

void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin) {
cyhal_gpio_configure(pin, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW);

// printf("2 SDA is CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW ? %ld\n", gpio_get_drive(CYBSP_I2C_SDA));
// printf("2 SCL is CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW ? %ld\n", gpio_get_drive(CYBSP_I2C_SCL));

// printf("SDA is CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW ? %d\n", (gpio_get_drive(CYBSP_I2C_SDA) & 0xFFFFFFF7) == CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW);
// printf("SCL is CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW ? %d\n", (gpio_get_drive(CYBSP_I2C_SCL) & 0xFFFFFFF7) == CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW);
}


Expand Down
2 changes: 1 addition & 1 deletion tests/psoc6/i2c_hard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###
### I2C
from machine import I2C

i2c = I2C(id=0, scl="P6_0", sda="P6_1", freq=400000)
Expand Down

0 comments on commit 5689ec7

Please sign in to comment.