- folder structure reordered
- unnecessary drivers removed
This commit is contained in:
18
source/firmware/kernel/include/ctx.h
Executable file
18
source/firmware/kernel/include/ctx.h
Executable file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* ctx.h
|
||||
*
|
||||
* Created on: Feb 20, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef CTX_H_
|
||||
#define CTX_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_ctx.h"
|
||||
#endif
|
||||
#ifdef ARCH_STM32F4XX
|
||||
#include "stm32f4xx_ctx.h"
|
||||
#endif
|
||||
|
||||
#endif /* CTX_H_ */
|
17
source/firmware/kernel/include/irq.h
Normal file
17
source/firmware/kernel/include/irq.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* irq.h
|
||||
*
|
||||
* Created on: Sep 25, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef IRQ_H_
|
||||
#define IRQ_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_irq.h"
|
||||
#endif
|
||||
#ifdef ARCH_STM32F4XX
|
||||
#include "stm32f4xx_irq.h"
|
||||
#endif
|
||||
#endif /* IRQ_H_ */
|
15
source/firmware/kernel/include/isr.h
Normal file
15
source/firmware/kernel/include/isr.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* isr.h
|
||||
*
|
||||
* Created on: Sep 25, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef ISR_H_
|
||||
#define ISR_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_isr.h"
|
||||
#endif
|
||||
|
||||
#endif /* ISR_H_ */
|
24
source/firmware/kernel/include/list.h
Normal file
24
source/firmware/kernel/include/list.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* list.h
|
||||
*
|
||||
* Created on: Jul 27, 2016
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef SOURCE_FIRMWARE_KERNEL_LIST_H_
|
||||
#define SOURCE_FIRMWARE_KERNEL_LIST_H_
|
||||
|
||||
struct list_node {
|
||||
struct list_node *next;
|
||||
unsigned int data;
|
||||
};
|
||||
|
||||
struct list {
|
||||
struct list_node *front;
|
||||
struct list_node *rear;
|
||||
};
|
||||
|
||||
int list_init(struct list *head);
|
||||
int list_add(struct list *head, struct list_node *node);
|
||||
|
||||
#endif /* SOURCE_FIRMWARE_KERNEL_LIST_H_ */
|
18
source/firmware/kernel/include/low_power.h
Executable file
18
source/firmware/kernel/include/low_power.h
Executable file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* low_power.h
|
||||
*
|
||||
* Created on: Feb 17, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef LOW_POWER_H_
|
||||
#define LOW_POWER_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_low_power.h"
|
||||
#endif
|
||||
#ifdef ARCH_STM32F4XX
|
||||
#include "stm32f4xx_low_power.h"
|
||||
#endif
|
||||
|
||||
#endif /* LOW_POWER_H_ */
|
26
source/firmware/kernel/include/queue.h
Normal file
26
source/firmware/kernel/include/queue.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* queue.h
|
||||
*
|
||||
* Created on: Oct 25, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef QUEUE_H_
|
||||
#define QUEUE_H_
|
||||
|
||||
struct queue_node {
|
||||
struct queue_node *next;
|
||||
unsigned int data;
|
||||
};
|
||||
|
||||
struct queue {
|
||||
struct queue_node *front;
|
||||
struct queue_node *rear;
|
||||
};
|
||||
|
||||
int queue_init(struct queue *head);
|
||||
int queue_push(struct queue *head, struct queue_node *node);
|
||||
int queue_pop(struct queue *head, struct queue_node *node);
|
||||
bool queue_is_empty(struct queue *head);
|
||||
|
||||
#endif /* QUEUE_H_ */
|
49
source/firmware/kernel/include/ringbuffer.h
Executable file
49
source/firmware/kernel/include/ringbuffer.h
Executable file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* ringbuffer.h
|
||||
*
|
||||
* Created on: Jul 24, 2012
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef RINGBUFFER_H_
|
||||
#define RINGBUFFER_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief A ring buffer object.
|
||||
struct ringbuffer {
|
||||
char *buffer; //!< The buffer.
|
||||
char *read; //!< Read access.
|
||||
char *write; //!< Write access.
|
||||
int size; //!< Buffer size.
|
||||
int used; //!< Buffer in use.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Read out n characters from ring buffer.
|
||||
//! \param this The ring buffer to read from.
|
||||
//! \param buffer to read to.
|
||||
//! \param size The maximum number of characters to read.
|
||||
//! \retval -1 in error case, otherwise the number of read characters.
|
||||
int ringbuffer_read(struct ringbuffer *this, char *buffer, int size);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Write n characters to ring buffer.
|
||||
//! \param this The ring buffer to write to.
|
||||
//! \param buffer to write.
|
||||
//! \param size The number of characters to write.
|
||||
//! \retval -1 in error case, otherwise the number of written characters.
|
||||
int ringbuffer_write(struct ringbuffer *this, const char *buffer, int size);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Check if ring buffer is full.
|
||||
//! \param this The ring buffer to check.
|
||||
//! \retval -1 in error case, otherwise 1 (true) / 0 (false).
|
||||
int ringbuffer_is_full(const struct ringbuffer *this);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Check if ring buffer is empty.
|
||||
//! \param this The ring buffer to check.
|
||||
//! \retval -1 in error case, otherwise 1 (true) / 0 (false).
|
||||
int ringbuffer_is_empty(const struct ringbuffer *this);
|
||||
|
||||
#endif /* RINGBUFFER_H_ */
|
21
source/firmware/kernel/include/schedule.h
Executable file
21
source/firmware/kernel/include/schedule.h
Executable file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* schedule.h
|
||||
*
|
||||
* Created on: Feb 20, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef SCHEDULE_H_
|
||||
#define SCHEDULE_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_schedule.h"
|
||||
#endif
|
||||
#ifdef ARCH_STM32F4XX
|
||||
#include "stm32f4xx_ctx.h"
|
||||
#endif
|
||||
|
||||
void schedule_start(void);
|
||||
#define schedule() arch_schedule()
|
||||
|
||||
#endif /* SCHEDULE_H_ */
|
20
source/firmware/kernel/include/semaphore.h
Normal file
20
source/firmware/kernel/include/semaphore.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* semaphore.h
|
||||
*
|
||||
* Created on: Oct 25, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef SEMAPHORE_H_
|
||||
#define SEMAPHORE_H_
|
||||
|
||||
struct semaphore {
|
||||
int cnt;
|
||||
struct queue queue;
|
||||
};
|
||||
|
||||
int semaphore_init(struct semaphore *sem, int value);
|
||||
int semaphore_wait(struct semaphore *sem);
|
||||
int semaphore_post(struct semaphore *sem);
|
||||
|
||||
#endif /* SEMAPHORE_H_ */
|
18
source/firmware/kernel/include/stack.h
Normal file
18
source/firmware/kernel/include/stack.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* stack.h
|
||||
*
|
||||
* Created on: Sep 27, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef STACK_H_
|
||||
#define STACK_H_
|
||||
|
||||
#ifdef ARCH_MSP430
|
||||
#include "msp430_stack.h"
|
||||
#endif
|
||||
#ifdef ARCH_STM32F4XX
|
||||
#include "stm32f4xx_stack.h"
|
||||
#endif
|
||||
|
||||
#endif /* STACK_H_ */
|
15
source/firmware/kernel/include/sys_tick.h
Normal file
15
source/firmware/kernel/include/sys_tick.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* sys_tick.h
|
||||
*
|
||||
* Created on: Sep 25, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef SYS_TICK_H_
|
||||
#define SYS_TICK_H_
|
||||
|
||||
void sys_tick_init(const struct loki_timer *hw_timer);
|
||||
|
||||
void sleep_ms(unsigned int ms);
|
||||
|
||||
#endif /* SYS_TICK_H_ */
|
61
source/firmware/kernel/include/thread.h
Normal file
61
source/firmware/kernel/include/thread.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* thread.h
|
||||
*
|
||||
* Created on: Apr 13, 2015
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef THREAD_H_
|
||||
#define THREAD_H_
|
||||
|
||||
#define MAX_THREAD_COUNT 32
|
||||
|
||||
enum thread_priority {
|
||||
THREAD_PRIO_IDLE = 0,
|
||||
THREAD_PRIO_LOW,
|
||||
THREAD_PRIO_MEDIUM,
|
||||
THREAD_PRIO_HIGH
|
||||
};
|
||||
|
||||
enum thread_status {
|
||||
THREAD_STATUS_INIT = 0,
|
||||
THREAD_STATUS_EXECUTING,
|
||||
THREAD_STATUS_WAITING,
|
||||
THREAD_STATUS_SLEEPING,
|
||||
THREAD_STATUS_BLOCKING
|
||||
};
|
||||
|
||||
struct thread_context {
|
||||
stack_t *sp; /**< thread's stack pointer */
|
||||
stack_t *stack; /**< thread's stack start address */
|
||||
unsigned int stack_size; /**< thread's stack size */
|
||||
unsigned int pid; /**< thread's process id */
|
||||
enum thread_priority priority; /**< thread's priority */
|
||||
enum thread_status status; /**< thread's status */
|
||||
unsigned long next_executing_time;
|
||||
void *wakeup_blocking_source;
|
||||
struct queue_node sem_queue_node;
|
||||
};
|
||||
|
||||
struct thread_list {
|
||||
unsigned int count; //<! Number of elements in list
|
||||
struct thread_context *list[MAX_THREAD_COUNT];
|
||||
};
|
||||
|
||||
void thread_init(void);
|
||||
struct thread_context *thread_create(
|
||||
struct thread_context *thread,
|
||||
stack_t *stack,
|
||||
unsigned int stack_size,
|
||||
void (*thread_func)(void *),
|
||||
void *arg,
|
||||
enum thread_priority priority);
|
||||
|
||||
void thread_switch_context(void);
|
||||
|
||||
void thread_exit(void);
|
||||
|
||||
void blocking_read_wakeup(const void *src);
|
||||
|
||||
|
||||
#endif /* THREAD_H_ */
|
Reference in New Issue
Block a user