moved all third-party lib to separate folder

This commit is contained in:
2021-02-27 19:32:58 +01:00
committed by Robin Mueller
parent 264191415f
commit fa81b06bea
138 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,60 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_CLOCK_H_
#define _CSP_CLOCK_H_
/**
@file
Clock API.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
Cross-platform timestamp.
*/
typedef struct {
//! Seconds
uint32_t tv_sec;
//! Nano-seconds.
uint32_t tv_nsec;
} csp_timestamp_t;
/**
Get time - must be implemented by the user.
*/
__attribute__((weak)) extern void clock_get_time(csp_timestamp_t * time);
/**
Set time - must be implemented by the user.
*/
__attribute__((weak)) extern void clock_set_time(csp_timestamp_t * time);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_CLOCK_H_

View File

@ -0,0 +1,39 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_MALLOC_H_
#define _CSP_MALLOC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
void * csp_malloc(size_t size);
void csp_free(void * ptr);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_MALLOC_H_

View File

@ -0,0 +1,49 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_QUEUE_H_
#define _CSP_QUEUE_H_
#ifdef __cplusplus
extern "C" {
#endif
#define CSP_QUEUE_FULL 0
#define CSP_QUEUE_ERROR 0
#define CSP_QUEUE_OK 1
typedef void * csp_queue_handle_t;
#include <stdint.h>
#include <csp/csp.h>
csp_queue_handle_t csp_queue_create(int length, size_t item_size);
void csp_queue_remove(csp_queue_handle_t queue);
int csp_queue_enqueue(csp_queue_handle_t handle, void *value, uint32_t timeout);
int csp_queue_enqueue_isr(csp_queue_handle_t handle, void * value, CSP_BASE_TYPE * task_woken);
int csp_queue_dequeue(csp_queue_handle_t handle, void *buf, uint32_t timeout);
int csp_queue_dequeue_isr(csp_queue_handle_t handle, void * buf, CSP_BASE_TYPE * task_woken);
int csp_queue_size(csp_queue_handle_t handle);
int csp_queue_size_isr(csp_queue_handle_t handle);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_QUEUE_H_

View File

@ -0,0 +1,109 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_SEMAPHORE_H_
#define _CSP_SEMAPHORE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <csp/csp.h>
/* POSIX interface */
#if defined(CSP_POSIX)
#include <pthread.h>
#include <semaphore.h>
#define CSP_SEMAPHORE_OK 1
#define CSP_SEMAPHORE_ERROR 2
#define CSP_MUTEX_OK CSP_SEMAPHORE_OK
#define CSP_MUTEX_ERROR CSP_SEMAPHORE_ERROR
typedef sem_t csp_bin_sem_handle_t;
typedef pthread_mutex_t csp_mutex_t;
#endif // CSP_POSIX
/* MAC OS X interface */
#if defined(CSP_MACOSX)
#include <pthread.h>
#include "posix/pthread_queue.h"
#define CSP_SEMAPHORE_OK PTHREAD_QUEUE_OK
#define CSP_SEMAPHORE_ERROR PTHREAD_QUEUE_EMPTY
#define CSP_MUTEX_OK CSP_SEMAPHORE_OK
#define CSP_MUTEX_ERROR CSP_SEMAPHORE_ERROR
typedef pthread_queue_t * csp_bin_sem_handle_t;
typedef pthread_queue_t * csp_mutex_t;
#endif // CSP_MACOSX
#if defined(CSP_WINDOWS)
#include <Windows.h>
#undef interface
#define CSP_SEMAPHORE_OK 1
#define CSP_SEMAPHORE_ERROR 2
#define CSP_MUTEX_OK CSP_SEMAPHORE_OK
#define CSP_MUTEX_ERROR CSP_SEMAPHORE_ERROR
typedef HANDLE csp_bin_sem_handle_t;
typedef HANDLE csp_mutex_t;
#endif
/* FreeRTOS interface */
#if defined(CSP_FREERTOS)
#include <FreeRTOS.h>
#include <semphr.h>
#define CSP_SEMAPHORE_OK pdPASS
#define CSP_SEMAPHORE_ERROR pdFAIL
#define CSP_MUTEX_OK CSP_SEMAPHORE_OK
#define CSP_MUTEX_ERROR CSP_SEMAPHORE_ERROR
typedef xSemaphoreHandle csp_bin_sem_handle_t;
typedef xSemaphoreHandle csp_mutex_t;
#endif // CSP_FREERTOS
int csp_mutex_create(csp_mutex_t * mutex);
int csp_mutex_remove(csp_mutex_t * mutex);
int csp_mutex_lock(csp_mutex_t * mutex, uint32_t timeout);
int csp_mutex_unlock(csp_mutex_t * mutex);
int csp_bin_sem_create(csp_bin_sem_handle_t * sem);
int csp_bin_sem_remove(csp_bin_sem_handle_t * sem);
int csp_bin_sem_wait(csp_bin_sem_handle_t * sem, uint32_t timeout);
int csp_bin_sem_post(csp_bin_sem_handle_t * sem);
int csp_bin_sem_post_isr(csp_bin_sem_handle_t * sem, CSP_BASE_TYPE * task_woken);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_SEMAPHORE_H_

View File

@ -0,0 +1,74 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_SYSTEM_H_
#define _CSP_SYSTEM_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define COLOR_MASK_COLOR 0x0F
#define COLOR_MASK_MODIFIER 0xF0
typedef enum {
/* Colors */
COLOR_RESET = 0xF0,
COLOR_BLACK = 0x01,
COLOR_RED = 0x02,
COLOR_GREEN = 0x03,
COLOR_YELLOW = 0x04,
COLOR_BLUE = 0x05,
COLOR_MAGENTA = 0x06,
COLOR_CYAN = 0x07,
COLOR_WHITE = 0x08,
/* Modifiers */
COLOR_NORMAL = 0x0F,
COLOR_BOLD = 0x10,
COLOR_UNDERLINE = 0x20,
COLOR_BLINK = 0x30,
COLOR_HIDE = 0x40,
} csp_color_t;
/**
* Writes out a task list into a pre-allocate buffer,
* use csp_sys_tasklist_size to get sizeof buffer to allocate
* @param out pointer to output buffer
* @return
*/
int csp_sys_tasklist(char * out);
/**
* @return Size of tasklist buffer to allocate for the csp_sys_tasklist call
*/
int csp_sys_tasklist_size(void);
uint32_t csp_sys_memfree(void);
int csp_sys_reboot(void);
int csp_sys_shutdown(void);
void csp_sys_set_color(csp_color_t color);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_SYSTEM_H_

View File

@ -0,0 +1,100 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_THREAD_H_
#define _CSP_THREAD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <csp/csp.h>
/* POSIX interface */
#if defined(CSP_POSIX) || defined(CSP_MACOSX)
#include <pthread.h>
#include <unistd.h>
#define csp_thread_exit() pthread_exit(NULL)
typedef pthread_t csp_thread_handle_t;
typedef void * csp_thread_return_t;
#define CSP_DEFINE_TASK(task_name) csp_thread_return_t task_name(void * param)
#define CSP_TASK_RETURN NULL
#define csp_sleep_ms(time_ms) usleep(time_ms * 1000);
#endif // CSP_POSIX
/* Windows interface */
#if defined(CSP_WINDOWS)
#include <Windows.h>
#undef interface
#include <process.h>
#define csp_thread_exit() _endthreadex(0)
typedef HANDLE csp_thread_handle_t;
typedef unsigned int csp_thread_return_t;
#define CSP_DEFINE_TASK(task_name) csp_thread_return_t __attribute__((stdcall)) task_name(void * param)
#define CSP_TASK_RETURN 0
#define csp_sleep_ms(time_ms) Sleep(time_ms);
#endif // CSP_WINDOWS
/* FreeRTOS interface */
#if defined(CSP_FREERTOS)
#include <FreeRTOS.h>
#include <task.h>
#if INCLUDE_vTaskDelete
#define csp_thread_exit() vTaskDelete(NULL)
#else
#define csp_thread_exit()
#endif
typedef xTaskHandle csp_thread_handle_t;
typedef void csp_thread_return_t;
#define CSP_DEFINE_TASK(task_name) csp_thread_return_t task_name(void * param)
#define CSP_TASK_RETURN
#define csp_sleep_ms(time_ms) vTaskDelay(time_ms / portTICK_RATE_MS);
#endif // CSP_FREERTOS
#ifndef CSP_WINDOWS
int csp_thread_create(csp_thread_return_t (* routine)(void *), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
#else
int csp_thread_create(csp_thread_return_t (* routine)(void *)__attribute__((stdcall)), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_THREAD_H_

View File

@ -0,0 +1,57 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSP_TIME_H_
#define _CSP_TIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <csp/csp.h>
/* Blackfin/x86 on Linux */
#if defined(CSP_POSIX)
#include <time.h>
#include <sys/time.h>
#include <limits.h>
#endif // CSP_POSIX
/* AVR/ARM on FreeRTOS */
#if defined(CSP_FREERTOS)
#include <FreeRTOS.h>
#include <task.h>
#endif // CSP_FREERTOS
uint32_t csp_get_ms(void);
uint32_t csp_get_ms_isr(void);
uint32_t csp_get_s(void);
uint32_t csp_get_s_isr(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _CSP_TIME_H_

View File

@ -0,0 +1,118 @@
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PTHREAD_QUEUE_H_
#define _PTHREAD_QUEUE_H_
/**
@file
Queue implemented using pthread locks and conds.
Inspired by c-pthread-queue by Matthew Dickinson: http://code.google.com/p/c-pthread-queue/
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <csp/arch/csp_queue.h>
/**
Queue error codes.
@{
*/
/**
General error code - something went wrong.
*/
#define PTHREAD_QUEUE_ERROR CSP_QUEUE_ERROR
/**
Queue is empty - cannot extract element.
*/
#define PTHREAD_QUEUE_EMPTY CSP_QUEUE_ERROR
/**
Queue is full - cannot insert element.
*/
#define PTHREAD_QUEUE_FULL CSP_QUEUE_ERROR
/**
Ok - no error.
*/
#define PTHREAD_QUEUE_OK CSP_QUEUE_OK
/** @{ */
/**
Queue handle.
*/
typedef struct pthread_queue_s {
//! Memory area.
void * buffer;
//! Memory size.
int size;
//! Item/element size.
int item_size;
//! Items/elements in queue.
int items;
//! Insert point.
int in;
//! Extract point.
int out;
//! Lock.
pthread_mutex_t mutex;
//! Wait because queue is full (insert).
pthread_cond_t cond_full;
//! Wait because queue is empty (extract).
pthread_cond_t cond_empty;
} pthread_queue_t;
/**
Create queue.
*/
pthread_queue_t * pthread_queue_create(int length, size_t item_size);
/**
Delete queue.
*/
void pthread_queue_delete(pthread_queue_t * q);
/**
Enqueue/insert element.
*/
int pthread_queue_enqueue(pthread_queue_t * queue, void * value, uint32_t timeout);
/**
Dequeue/extract element.
*/
int pthread_queue_dequeue(pthread_queue_t * queue, void * buf, uint32_t timeout);
/**
Return number of elements in the queue.
*/
int pthread_queue_items(pthread_queue_t * queue);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // _PTHREAD_QUEUE_H_