fixed the bug

sipo
Ondřej Hruška 7 years ago
parent 71f5918e54
commit 645619e9c5
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      framework/settings.c
  2. 1
      framework/unit_registry.c
  3. 2
      units/digital_in/unit_din.c
  4. 2
      units/digital_out/unit_dout.c
  5. 21
      units/i2c/unit_i2c.c
  6. 1
      units/neopixel/unit_neopixel.c

@ -270,7 +270,7 @@ void settings_load_ini_begin(void)
void settings_load_ini_key(const char *restrict section, const char *restrict key, const char *restrict value)
{
dbg("[%s] %s = %s", section, key, value);
// dbg("[%s] %s = %s", section, key, value);
static char namebuf[INI_KEY_MAX];
// SYSTEM and UNITS files must be separate.

@ -74,6 +74,7 @@ static void free_le_unit(UlistEntry *le)
{
Unit *const pUnit = &le->unit;
assert_param(pUnit->data);
pUnit->driver->deInit(pUnit);
// Name is not expected to be freed by the deInit() function
// - was alloc'd in the settings load loop

@ -164,6 +164,8 @@ static void DI_deInit(Unit *unit)
struct priv *priv = unit->data;
if (unit->status == E_SUCCESS) {
assert_param(priv->port);
bool suc = true;
uint16_t mask = 1;
for (int i = 0; i < 16; i++, mask <<= 1) {

@ -155,6 +155,8 @@ static void DO_deInit(Unit *unit)
// de-init the pins only if inited correctly
if (unit->status == E_SUCCESS) {
assert_param(priv->port);
bool suc = true;
uint16_t mask = 1;
for (int i = 0; i < 16; i++, mask <<= 1) {

@ -193,24 +193,24 @@ static error_t UI2C_init(Unit *unit)
TRY(rsc_claim(unit, r_sda));
TRY(rsc_claim(unit, r_scl));
GPIO_TypeDef *port = port2periph(portname, &suc);
priv->port = port2periph(portname, &suc);
uint32_t ll_pin_scl = pin2ll(pin_scl, &suc);
uint32_t ll_pin_sda = pin2ll(pin_sda, &suc);
if (!suc) return E_BAD_CONFIG;
// configure AF
if (pin_scl < 8) LL_GPIO_SetAFPin_0_7(port, ll_pin_scl, af_i2c);
else LL_GPIO_SetAFPin_8_15(port, ll_pin_scl, af_i2c);
if (pin_scl < 8) LL_GPIO_SetAFPin_0_7(priv->port, ll_pin_scl, af_i2c);
else LL_GPIO_SetAFPin_8_15(priv->port, ll_pin_scl, af_i2c);
if (pin_sda < 8) LL_GPIO_SetAFPin_0_7(port, ll_pin_sda, af_i2c);
else LL_GPIO_SetAFPin_8_15(port, ll_pin_sda, af_i2c);
if (pin_sda < 8) LL_GPIO_SetAFPin_0_7(priv->port, ll_pin_sda, af_i2c);
else LL_GPIO_SetAFPin_8_15(priv->port, ll_pin_sda, af_i2c);
LL_GPIO_SetPinMode(port, ll_pin_scl, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinMode(port, ll_pin_sda, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinMode(priv->port, ll_pin_scl, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinMode(priv->port, ll_pin_sda, LL_GPIO_MODE_ALTERNATE);
// set as OpenDrain (this may not be needed - TODO check)
LL_GPIO_SetPinOutputType(port, ll_pin_scl, LL_GPIO_OUTPUT_OPENDRAIN);
LL_GPIO_SetPinOutputType(port, ll_pin_sda, LL_GPIO_OUTPUT_OPENDRAIN);
LL_GPIO_SetPinOutputType(priv->port, ll_pin_scl, LL_GPIO_OUTPUT_OPENDRAIN);
LL_GPIO_SetPinOutputType(priv->port, ll_pin_sda, LL_GPIO_OUTPUT_OPENDRAIN);
if (priv->periph_num == 1) {
@ -243,6 +243,9 @@ static void UI2C_deInit(Unit *unit)
// de-init the pins & peripheral only if inited correctly
if (unit->status == E_SUCCESS) {
assert_param(priv->periph);
assert_param(priv->port);
LL_I2C_DeInit(priv->periph);
if (priv->periph_num == 1) {

@ -124,6 +124,7 @@ static void Npx_deInit(Unit *unit)
struct priv *priv = unit->data;
if (unit->status == E_SUCCESS) {
assert_param(priv->port);
// configure the pin as analog
LL_GPIO_SetPinMode(priv->port, priv->ll_pin, LL_GPIO_MODE_ANALOG);
}

Loading…
Cancel
Save