Created
November 13, 2017 10:31
-
-
Save a46554/67e47af22c03feaa9ac15cd94364d9bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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