Function that takes a reference to another function with no arguments

Viewed 42

I am wondering how the RecieveInit function takes the CMD_GetChar function as an argument with no parameters. From what I understand, the ReceiveInit takes an rxChar argument which is a pointer to a uint8_t. It is then cast as a pointer to a void object (*RxCb), where CMD_GetChar takes a pointer to a uint8_t.

void CMD_Init(void)
{
  ReceiveInit( CMD_GetChar );
}

void ReceiveInit(  void (*RxCb)(uint8_t *rxChar) )
{
}

static void CMD_GetChar( uint8_t* rxChar)
{
}

How is CMD_GetChar being computed within ReceiveInit when it doesn't even have an argument to parse?

0 Answers
Related