This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

First I2C code on nRF Connect, I think I'm close

Crawling up the learning curve here, doing my best to solve my own problems, but I'm down to just permuting things on this one and I'm not making much progress and all the examples I can find just seem a  little different to what I want to do..
Trying to get an nRF52833 dev kit talking I2C to an eeprom.

Overlay file

&i2c0 {
  compatible = "nordic,nrf-twi";
  status = "okay";
  sda-pin = <26>;
  scl-pin = <27>;
  clock-frequency = <100000>;
   my_eeprom:nRF52833@28 {
     status = "okay";
     reg = <0x28>;
     label = "config_eeprom";
   };
 
};

proj.conf

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_L2CAP_TX_BUF_COUNT=5
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Woggle"
CONFIG_BT_DEVICE_APPEARANCE=962
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_I2C=y
CONFIG_GPIO=y
# This example requires more workqueue stack

CONFIG_LOG=y

my code

#define twi0 DT_LABEL(DT_ALIAS(my_eeprom))

voi dmain(void)
{
        int err = 0;

   
    LOG_INF("Starting LiftlogDX\n");

    //init I2C
    const struct device *i2cdev=device_get_binding(twi0);
    i2c_configure(i2cdev, I2C_SPEED_SET(I2C_SPEED_STANDARD));

The Error:
DT_N_ALIAS_my_eeprom_P_label" is undefined 

I feel close, but it's eluding me..
Tips?

Parents
  • So here's where I got to:
    I went through the fujitsu example and got my head around the difference between writing a driver and just spitting I2C out. You don't need the second bit in the overlay file:

    my_eeprom:nRF52833@28 {
         status = "okay";
         reg = <0x28>;
         label = "config_eeprom";
       };

    If you just want to drive the bus directly.

    Then I went over the tutorial and got aliases an nodelabels back in my head and managed to get a reference to the device. This got me past the problem that generated this post.

    Next I wrote a simple, blocking, library and that more or less just worked.

    So I'm moving forward again!

    I'm storing a whole bunch of config information on the eeprom, The product can't really do anything until this is loaded, so a blocking implementation is mostly OK. I can wear some delays on writes too.  

    I'll revisit this later and get it playing nice with threads...
    Many thanks to all...

Reply
  • So here's where I got to:
    I went through the fujitsu example and got my head around the difference between writing a driver and just spitting I2C out. You don't need the second bit in the overlay file:

    my_eeprom:nRF52833@28 {
         status = "okay";
         reg = <0x28>;
         label = "config_eeprom";
       };

    If you just want to drive the bus directly.

    Then I went over the tutorial and got aliases an nodelabels back in my head and managed to get a reference to the device. This got me past the problem that generated this post.

    Next I wrote a simple, blocking, library and that more or less just worked.

    So I'm moving forward again!

    I'm storing a whole bunch of config information on the eeprom, The product can't really do anything until this is loaded, so a blocking implementation is mostly OK. I can wear some delays on writes too.  

    I'll revisit this later and get it playing nice with threads...
    Many thanks to all...

Children
No Data
Related