testprogramm.c
von blan- SNIPPET_TEXT:
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #define FIFO_SUCCESS 0x00
- #define FIFO_ERROR -0x01
- #define TRUE 0x01
- #define FALSE 0x00
- #define NULLPOINTER 0x00
- #define NULLBYTE '\0'
- typedef unsigned char uint8_t;
- typedef struct
- {
- uint8_t size;
- } fragment_t;
- typedef struct
- {
- uint8_t size;
- int8_t *data;
- fragment_t fragment;
- } fifo_t;
- fifo_t *fifo_new(uint8_t size, uint8_t fragment);
- int8_t fifo_push(volatile fifo_t *fifo, const int8_t *data);
- int8_t fifo_pop(volatile const fifo_t *fifo, int8_t *data);
- uint8_t fifo_get_size(volatile const fifo_t *fifo);
- uint8_t fifo_get_fragment_size(volatile const fifo_t *fifo);
- uint8_t fifo_get_data_size(volatile const fifo_t *fifo);
- void fifo_destroy(volatile fifo_t *fifo);
- int8_t fifo_flush(volatile fifo_t *fifo)
- {
- if(fifo == NULLPOINTER)
- {
- return FIFO_ERROR;
- }
- {
- return FIFO_SUCCESS;
- }
- else
- {
- return FIFO_ERROR;
- }
- }
- int main()
- {
- fifo_t *fifo_rx = fifo_new(8, 1);
- fifo_push(fifo_rx, "halloabc");
- int i;
- for(i = 0; i < 9; i++)
- {
- }
- //fifo_flush(fifo_rx);
- int8_t data = 0x69;
- fifo_pop(fifo_rx, &data);
- //fifo_pop(fifo_rx, &data);
- //printf("%c\n", data);
- for(i = 0; i < 9; i++)
- {
- }
- fifo_destroy(fifo_rx);
- }
- fifo_t *fifo_new(uint8_t size, uint8_t fragment)
- {
- if(size % fragment != 0)
- {
- return NULLPOINTER;
- }
- if(fifo == NULLPOINTER)
- {
- return NULLPOINTER;
- }
- else
- {
- fifo->size = size;
- fifo->fragment.size = fragment;
- if(fifo->data)
- {
- {
- return fifo;
- }
- else
- {
- return NULLPOINTER;
- }
- }
- else
- {
- return NULLPOINTER;
- }
- }
- }
- int8_t fifo_push(volatile fifo_t *fifo, const int8_t *data)
- {
- if(fifo == NULLPOINTER)
- {
- return FIFO_ERROR;
- }
- if(data == NULLPOINTER)
- {
- return FIFO_ERROR;
- }
- {
- return FIFO_ERROR;
- }
- else
- {
- {
- return FIFO_SUCCESS;
- }
- else
- {
- return FIFO_ERROR;
- }
- }
- }
- int8_t fifo_pop(volatile const fifo_t *fifo, int8_t *data)
- {
- if(fifo == NULLPOINTER)
- {
- return FIFO_ERROR;
- }
- if(data == NULLPOINTER)
- {
- return FIFO_ERROR;
- }
- {
- {
- {
- return FIFO_SUCCESS;
- }
- else
- {
- return FIFO_ERROR;
- }
- }
- else
- {
- return FIFO_ERROR;
- }
- }
- else
- {
- return FIFO_ERROR;
- }
- }
- void fifo_destroy(volatile fifo_t *fifo)
- {
- if(fifo != NULLPOINTER)
- {
- }
- }
Quellcode
Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN