Skip to content
Snippets Groups Projects
Commit 175300e5 authored by Ludwig Knüpfer's avatar Ludwig Knüpfer
Browse files

add native cpu doxygen documentation,

also fix and improve some of the existing
parent 512d5aab
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,10 @@ and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
/**
* @ingroup rtc
*/
#include <string.h>
#include <signal.h>
#include <irq.h>
......
......@@ -26,6 +26,7 @@ and the mailinglist (subscription via web site)
/**
* @ingroup lpc2387
* @ingroup lpm
* @{
*/
......
/**
* Native CPU hwtimer_arch.h implementation
*
* Uses POSIX real-time extension timers to mimic hardware timers.
* XXX: see hwtimer_isr_timer()
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @ingroup hwtimer
* @ingroup native_cpu
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @file
* @}
*/
......@@ -33,18 +37,29 @@ static int native_hwtimer_irq[ARCH_MAXTIMERS];
static timer_t native_hwtimer_timer[ARCH_MAXTIMERS];
static void (*int_handler)(int);
/**
* sets timespec to given ticks
*/
void ticks2ts(unsigned long ticks, struct timespec *tp)
{
tp->tv_sec = ticks / HWTIMER_SPEED;
tp->tv_nsec = (ticks % HWTIMER_SPEED)*1000 ;
}
/**
* returns ticks for give timespec
*/
unsigned long ts2ticks(struct timespec *tp)
{
/* TODO: check for overflow */
return((tp->tv_sec * HWTIMER_SPEED) + (tp->tv_nsec/1000));
}
/**
* native timer signal handler,
*
* XXX: Calls callback for all timers whenever any timer finishes.
*/
void hwtimer_isr_timer()
{
DEBUG("hwtimer_isr_timer()\n");
......@@ -95,10 +110,6 @@ void hwtimer_arch_unset(short timer)
return;
}
/**
* Set a kernel timer to raise an interrupt after ::offset kernel timer ticks
* from now.
*/
void hwtimer_arch_set(unsigned long offset, short timer)
{
struct itimerspec its;
......
/**
* Native CPU interface
*
* The native CPU uses system calls to simulate hardware access.
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
*/
/**
* @ingroup arch
* @defgroup native_cpu Native CPU
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/
#ifndef _CPU_H
......@@ -30,8 +33,18 @@
void dINT(void);
void eINT(void);
/**
* register interrupt handler handler for interrupt sig
*/
int register_interrupt(int sig, void *handler);
/**
* unregister interrupt handler for interrupt sig
*/
int unregister_interrupt(int sig);
/* this should be defined elsewhere */
void thread_yield(void);
/** @} */
#endif //_CPU_H
......@@ -6,8 +6,8 @@
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @{
* @ingroup native_hwtimer
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
......
/**
* Native CPU irq.h implementation
*
* uses POSIX real-time extension signals to create interrupts
* TODO: needs to be rewritten for better portability
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @ingroup native_cpu
* @ingroup irq
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/
#include <signal.h>
#include <err.h>
......@@ -34,6 +37,9 @@ struct int_handler_t {
};
static struct int_handler_t native_irq_handlers[255];
/**
* block signals
*/
unsigned disableIRQ(void)
{
unsigned int prev_state;
......@@ -60,6 +66,9 @@ unsigned disableIRQ(void)
return prev_state;
}
/**
* unblock signals
*/
unsigned enableIRQ(void)
{
unsigned int prev_state;
......@@ -181,8 +190,10 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
}
/**
* register signal/interrupt handler for signal sig
*
* TODO: check sa_flags for appropriateness
* TODO: use appropriate data structure (hashmap?) for signal
* TODO: use appropriate data structure for signal
* handlers.
*/
int register_interrupt(int sig, void *handler)
......@@ -212,6 +223,8 @@ int register_interrupt(int sig, void *handler)
}
/**
* empty signal mask
*
* TODO: see register_interrupt
* TODO: ignore signal
*/
......@@ -239,6 +252,9 @@ int unregister_interrupt(int sig)
/**
* register internal signal handler,
* initalize local variables
*
* TODO: see register_interrupt
*/
void native_interrupt_init(void)
......@@ -269,3 +285,4 @@ void native_interrupt_init(void)
puts("RIOT native interrupts/signals initialized.");
}
/** @} */
/**
* Native CPU lpm.h implementation
*
* Uses system calls to emulate CPU power modes.
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @ingroup lpm
* @ingroup native_cpu
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
......@@ -28,6 +31,11 @@ void lpm_init(void)
return;
}
/**
* LPM_IDLE uses sleep() to wait for interrupts
* LPM_OFF exits process
* other modes not supported at the moment
*/
enum lpm_mode lpm_set(enum lpm_mode target)
{
enum lpm_mode last_lpm;
......@@ -90,6 +98,7 @@ void lpm_end_awake(void)
native_lpm = LPM_ON;
return;
}
enum lpm_mode lpm_get(void)
{
return native_lpm;
......
/**
* Native CPU kernel_intern.h and sched.h implementation
*
* in-process preemptive context switching utilizes POSIX ucontexts.
* (ucontext provides for architecture independent stack handling)
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @ingroup native_cpu
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/
#include <stdio.h>
#include <ucontext.h>
......@@ -109,3 +111,4 @@ void native_cpu_init()
makecontext(&native_context, sched_task_exit, 0);
puts("RIOT native cpu initialized.");
}
/** @} */
/**
* Native CPU rtc.h implementation
*
* The native rtc implementation uses POSIX system calls to simulate a
* real-time clock.
*
* Setting the clock will be implemented using a delta variable.
*
* Copyright (C) 2013 Ludwig Ortmann
*
* This file subject to the terms and conditions of the GNU General Public
* License. See the file LICENSE in the top level directory for more details.
*
* @ingroup arch
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*
* @ingroup native_cpu
* @ingroup rtc
* @file
*/
#include <time.h>
......@@ -22,47 +27,30 @@
static int native_rtc_enabled;
/**
* @brief Initializes the RTC for calendar mode
*/
void rtc_init(void)
{
native_rtc_enabled = 0;
printf("native rtc initialized\n");
}
/**
* @brief Starts the RTC
*/
void rtc_enable(void)
{
DEBUG("rtc_enable\n");
native_rtc_enabled = 1;
}
/**
* @brief Stops the RTC
*/
void rtc_disable(void)
{
DEBUG("rtc_disable()\n");
native_rtc_enabled = 0;
}
/**
* @brief Sets the current time in broken down format directly from to RTC
* @param[in] localt Pointer to structure with time to set
*/
void rtc_set_localtime(struct tm* localt)
{
DEBUG("rtc_set_localtime()\n");
printf("setting time not supported.");
}
/**
* @brief Returns the current time in broken down format directly from the RTC
* @param[out] localt Pointer to structure to receive time
*/
void rtc_get_localtime(struct tm* localt)
{
time_t t;
......
......@@ -29,7 +29,7 @@ and the mailinglist (subscription via web site)
/**
* @defgroup ltc4150 LTC4150 Coulomb Counter
* @ingroup coulomb
* @ingroup drivers
* @{
*/
......@@ -48,11 +48,21 @@ and the mailinglist (subscription via web site)
#define _R_SENSE (double)0.330
#define SUPPLY_VOLTAGE (5)
/** board specific ltc4150 interrupt disable */
void ltc4150_disable_int(void);
/** board specific ltc4150 interrupt enable */
void ltc4150_enable_int(void);
/** board specific synchronization of ltc4150 */
void ltc4150_sync_blocking(void);
/** board specific ltc4150 initialization */
void ltc4150_arch_init(void);
/**
* ltc4150 interrupt handler,
* shall be called on ltc4150 interrupt,
* implemented in driver
*/
void ltc4150_interrupt(void);
/** @} */
/** * @} */
#endif /* __LTC4150_ARCH_H */
......@@ -24,6 +24,12 @@ and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
/**
* @defgroup rtc Realtime Clock
* @ingroup drivers
* @{
*/
#ifndef RTC_H
#define RTC_H
......@@ -61,3 +67,4 @@ void rtc_get_localtime(struct tm* localt);
extern int rtc_second_pid;
#endif
/** @} */
......@@ -27,7 +27,7 @@ and the mailinglist (subscription via web site)
/**
* @defgroup sht11 Sensirion SHT11 Driver
* @ingroup dev
* @ingroup drivers
* @{
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment