Skip to content

Instantly share code, notes, and snippets.

@a46554
Created November 13, 2017 10:31
Show Gist options
  • Save a46554/67e47af22c03feaa9ac15cd94364d9bf to your computer and use it in GitHub Desktop.
Save a46554/67e47af22c03feaa9ac15cd94364d9bf to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define UNUSED(x) (void)(x)
typedef unsigned char uint8_t;
typedef struct
uint8_t (*send)(uint8_t *data, uint8_t len);
uint8_t (*read)(uint8_t *data, uint8_t len);
} interface;
uint8_t uart1send(void *p_context){
UNUSED(p_context);
printf("%d", (int)p_context);
return 1;
}
int main(void){
interface uart1, uart2;
uart1.send = uart1send;
uart1.send((void*)'a');
uart2.send = uart1send;
uart1.send((void*)'b');
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment