-2

i am new to c++ or freertos but i am trying to only use 1 pin to power an external led but i get the error

expected primary-expression before ',' token
     GPIO_PinWrite(led, led_pin, 0u)

i also get this ^^ with the other pin write

this was fixed by deleting the semicoloms behind the define

i don't specificaly know how to make an gpio pinWrite but i copied the one that is in the example of the baremetal function.

this is my task i am using an imxrt1050-evkb

**this is standard import by MCUXpresso**
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MIMXRT1052.h"
#include "fsl_debug_console.h"

**this is freeRTOS**
#include "FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"


#define led SEMC_D12;
#define led_pin GPIO_EMC_34;

volatile bool g_pinSet = false;


void vOnOff(void *pvParameters)
{
    while(true){
            vTaskDelay(200);
            PRINTF("Hello led\n");
            if(g_pinSet)
            {
                GPIO_PinWrite(led, led_pin, 1u);
                g_pinSet = true;
            }
            else
            {
                GPIO_PinWrite(led, led_pin, 0u);
                g_pinSet = false;
            }

}

}
int main(void) {
     gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
    /* Init board hardware. */
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();
    /* Init FSL debug console. */
    BOARD_InitDebugConsole();

//    GPIO_PinInit(led , led_pin , &led_config);

    xTaskCreate(
            (TaskFunction_t) vOnOff,
            "task3",
            configMINIMAL_STACK_SIZE,
            NULL,
            10,
            NULL
    );
    vTaskStartScheduler();
    return 0 ;
}

i believe the code here ^^ is all the good i use for this example becouse i am working in an sandbox with spaghetti code everywhere

as you can see in my code i got GPIO_PinInit commented i don't know if i need to use that?

i expect to send an signal on and of to an io pin

Marc Roelse
  • 95
  • 1
  • 12

1 Answers1

1

FreeRTOS is a RTOS abstraction - it has nothing to do with handling gpio.

#define led SEMC_D12;
#define led_pin GPIO_EMC_34;

Are invalid. There should be no ; after the macro definition. Because there is ;, compiler sees:

GPIO_PinWrite(SEMC_D12;, GPIO_EMC_34;, 0u)

and exists with compilation error.

The MCUXpresso SDK API Reference Manual says that:

static void GPIO_PinWrite (GPIO_Type *base, uint32_t port, uint32_t pin, uint8_t output)

I guess you need 4 parameters to GPIO_PinWrite, not 3.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • thanks for the explanations of why there shouldn't be an ; behind define. – Marc Roelse Sep 04 '19 at 12:12
  • Because #define isn't handled by the compiler, it is handled by the preprocessor. for a statement #define q1 q2 all it does is literally replace every occurrence of q1 with q2. As said in the post, this would cause unnecessary semicolons to be placed in the code when it gets to compile time. – BTables Sep 04 '19 at 12:28