Report
4 months, 2 weeks ago.  This question has been closed. Reason: Too broad - no single answer

Cannot compile with up-to-date Microbit-dal

EDIT: I closed this question as I started again from a blank canvas and that's working.

Starting with the Blinky sample, which compiles OK, I then switched from mbed.h to MicroBit.h, which initially throws an error about pin definitions p4 and p13

Error: Identifier "p13" is undefined in "microbit/microbit-dal/inc/drivers/MicroBitMatrixMaps.h", Line: 155, Col: 6

Error: Identifier "p4" is undefined in "microbit/microbit-dal/inc/drivers/MicroBitMatrixMaps.h", Line: 156, Col: 6

. ..until I do two things:

Update the library/s

Add my own header file which contains the lower case pin definitions from https://github.com/lancaster-university/microbit-dal/blob/master/inc/drivers/MicroBitPin.h

This gets me to the following compile errors:

  Error: Too few arguments in function call in "microbit/microbit-dal/source/drivers/MicroBitI2C.cpp", Line: 85, Col: 36
  Error: Too few arguments in function call in "microbit/microbit-dal/source/drivers/MicroBitI2C.cpp", Line: 124, Col: 36

These refer to twi_master_init_and_clear()

At that point I am stopping because I am new to C/C++ on the microbit and also the mbed environment and I don't want to go down an unnecessary rabbit hole, but felt it worth documenting my experience for others who follow in my wake. I'd appreciate any guidance/RTFM material etc.

My main code:

//#include "mbed.h"
#include "nkpins.h"
#include "MicroBit.h"

/*
 * All the LEDs on the micro:bit are part of the LED Matrix,
 * In order to get simple blinking behaviour, we set column 0
 * to be permanently at ground. If you want to use the LEDs as
 * a screen, there is a display driver in the micro:bit 'DAL',
 */
//DigitalOut col0(P0_4, 0);

DigitalOut myled(p1); //MICROBIT_PIN_P1 

int main()
{
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

With nkpins just being:

#define p0                     P0_3        //P0 is the left most pad (ANALOG/DIGITAL) used to be P0_3 on green board
#define p1                     P0_2        //P1 is the middle pad (ANALOG/DIGITAL)
#define p2                     P0_1        //P2 is the right most pad (ANALOG/DIGITAL) used to be P0_1 on green board
#define p3                     P0_4        //COL1 (ANALOG/DIGITAL)
#define p4                     P0_5        //COL2 (ANALOG/DIGITAL)
#define p5                     P0_17       //BTN_A
#define p6                     P0_12       //COL9
#define p7                     P0_11       //COL8
#define p8                     P0_18       //PIN 18
#define p9                     P0_10       //COL7
#define p10                    P0_6        //COL3 (ANALOG/DIGITAL)
#define p11                    P0_26       //BTN_B
#define p12                    P0_20       //PIN 20
#define p13                    P0_23       //SCK
#define p14                    P0_22       //MISO
#define p15                    P0_21       //MOSI
#define p16                    P0_16       //PIN 16
#define p19                    P0_0        //SCL
#define p20                    P0_30       //SDA

Question relating to:

The BBC micro:bit is a pocket-sized, codable computer that allows anyone to get creative with technology. Made possible through a major partnership with 31 organisations, a micro:bit has been given ...

To post an answer, please log in.