Skip to content
Snippets Groups Projects
Commit ec11e9b1 authored by Oleg Hahm's avatar Oleg Hahm
Browse files

Merge pull request #26 from LudwigOrtmann/master

added and improved doxygen documentation
parents 7cef6c46 1a628ee8
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,10 @@ and the mailinglist (subscription via web site) ...@@ -24,6 +24,10 @@ and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/ *******************************************************************************/
/**
* @ingroup rtc
*/
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <irq.h> #include <irq.h>
......
...@@ -26,6 +26,7 @@ and the mailinglist (subscription via web site) ...@@ -26,6 +26,7 @@ and the mailinglist (subscription via web site)
/** /**
* @ingroup lpc2387 * @ingroup lpc2387
* @ingroup lpm
* @{ * @{
*/ */
......
/** /**
* Native CPU hwtimer_arch.h implementation * 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 * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * 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> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @file
* @} * @}
*/ */
...@@ -26,25 +30,34 @@ ...@@ -26,25 +30,34 @@
#include "debug.h" #include "debug.h"
#define HWTIMER_MINTICKS (1000)
static unsigned long native_hwtimer_now; static unsigned long native_hwtimer_now;
static int native_hwtimer_irq[ARCH_MAXTIMERS]; static int native_hwtimer_irq[ARCH_MAXTIMERS];
static timer_t native_hwtimer_timer[ARCH_MAXTIMERS]; static timer_t native_hwtimer_timer[ARCH_MAXTIMERS];
static void (*int_handler)(int); static void (*int_handler)(int);
/**
* sets timespec to given ticks
*/
void ticks2ts(unsigned long ticks, struct timespec *tp) void ticks2ts(unsigned long ticks, struct timespec *tp)
{ {
tp->tv_sec = ticks / HWTIMER_SPEED; tp->tv_sec = ticks / HWTIMER_SPEED;
tp->tv_nsec = (ticks % HWTIMER_SPEED)*1000 ; tp->tv_nsec = (ticks % HWTIMER_SPEED)*1000 ;
} }
/**
* returns ticks for give timespec
*/
unsigned long ts2ticks(struct timespec *tp) unsigned long ts2ticks(struct timespec *tp)
{ {
/* TODO: check for overflow */ /* TODO: check for overflow */
return((tp->tv_sec * HWTIMER_SPEED) + (tp->tv_nsec/1000)); 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() void hwtimer_isr_timer()
{ {
DEBUG("hwtimer_isr_timer()\n"); DEBUG("hwtimer_isr_timer()\n");
...@@ -95,10 +108,6 @@ void hwtimer_arch_unset(short timer) ...@@ -95,10 +108,6 @@ void hwtimer_arch_unset(short timer)
return; 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) void hwtimer_arch_set(unsigned long offset, short timer)
{ {
struct itimerspec its; struct itimerspec its;
......
/** /**
* Native CPU interface * Native CPU interface
* *
* The native CPU uses system calls to simulate hardware access.
*
* Copyright (C) 2013 Ludwig Ortmann * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* */
/**
* @ingroup arch * @ingroup arch
* @defgroup native_cpu Native CPU
* @{ * @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/ */
#ifndef _CPU_H #ifndef _CPU_H
...@@ -30,8 +33,18 @@ ...@@ -30,8 +33,18 @@
void dINT(void); void dINT(void);
void eINT(void); void eINT(void);
/**
* register interrupt handler handler for interrupt sig
*/
int register_interrupt(int sig, void *handler); int register_interrupt(int sig, void *handler);
/**
* unregister interrupt handler for interrupt sig
*/
int unregister_interrupt(int sig); int unregister_interrupt(int sig);
/* this should be defined elsewhere */
void thread_yield(void); void thread_yield(void);
/** @} */
#endif //_CPU_H #endif //_CPU_H
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* *
* @ingroup arch
* @{ * @{
* @ingroup native_hwtimer
* @file * @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @} * @}
......
/** /**
* Native CPU irq.h implementation * 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 * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* *
* @ingroup arch * @ingroup native_cpu
* @ingroup irq
* @{ * @{
* @file * @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/ */
#include <signal.h> #include <signal.h>
#include <err.h> #include <err.h>
...@@ -34,6 +37,9 @@ struct int_handler_t { ...@@ -34,6 +37,9 @@ struct int_handler_t {
}; };
static struct int_handler_t native_irq_handlers[255]; static struct int_handler_t native_irq_handlers[255];
/**
* block signals
*/
unsigned disableIRQ(void) unsigned disableIRQ(void)
{ {
unsigned int prev_state; unsigned int prev_state;
...@@ -60,6 +66,9 @@ unsigned disableIRQ(void) ...@@ -60,6 +66,9 @@ unsigned disableIRQ(void)
return prev_state; return prev_state;
} }
/**
* unblock signals
*/
unsigned enableIRQ(void) unsigned enableIRQ(void)
{ {
unsigned int prev_state; unsigned int prev_state;
...@@ -181,8 +190,10 @@ void native_isr_entry(int sig, siginfo_t *info, void *context) ...@@ -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: check sa_flags for appropriateness
* TODO: use appropriate data structure (hashmap?) for signal * TODO: use appropriate data structure for signal
* handlers. * handlers.
*/ */
int register_interrupt(int sig, void *handler) int register_interrupt(int sig, void *handler)
...@@ -212,6 +223,8 @@ 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: see register_interrupt
* TODO: ignore signal * TODO: ignore signal
*/ */
...@@ -232,13 +245,16 @@ int unregister_interrupt(int sig) ...@@ -232,13 +245,16 @@ int unregister_interrupt(int sig)
sa.sa_flags = SA_RESTART | SA_SIGINFO; sa.sa_flags = SA_RESTART | SA_SIGINFO;
if (sigaction(sig, &sa, NULL)) { if (sigaction(sig, &sa, NULL)) {
err(1, "register_interrupt: sigaction"); err(1, "unregister_interrupt: sigaction");
} }
return 0; return 0;
} }
/** /**
* register internal signal handler,
* initalize local variables
*
* TODO: see register_interrupt * TODO: see register_interrupt
*/ */
void native_interrupt_init(void) void native_interrupt_init(void)
...@@ -269,3 +285,4 @@ void native_interrupt_init(void) ...@@ -269,3 +285,4 @@ void native_interrupt_init(void)
puts("RIOT native interrupts/signals initialized."); puts("RIOT native interrupts/signals initialized.");
} }
/** @} */
/** /**
* Native CPU lpm.h implementation * Native CPU lpm.h implementation
* *
* Uses system calls to emulate CPU power modes.
*
* Copyright (C) 2013 Ludwig Ortmann * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* *
* @ingroup arch * @ingroup lpm
* @ingroup native_cpu
* @{ * @{
* @file * @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
...@@ -28,6 +31,11 @@ void lpm_init(void) ...@@ -28,6 +31,11 @@ void lpm_init(void)
return; 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 lpm_set(enum lpm_mode target)
{ {
enum lpm_mode last_lpm; enum lpm_mode last_lpm;
...@@ -90,6 +98,7 @@ void lpm_end_awake(void) ...@@ -90,6 +98,7 @@ void lpm_end_awake(void)
native_lpm = LPM_ON; native_lpm = LPM_ON;
return; return;
} }
enum lpm_mode lpm_get(void) enum lpm_mode lpm_get(void)
{ {
return native_lpm; return native_lpm;
......
/** /**
* Native CPU kernel_intern.h and sched.h implementation * 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 * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* *
* @ingroup arch * @ingroup native_cpu
* @{ * @{
* @file * @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @}
*/ */
#include <stdio.h> #include <stdio.h>
#include <ucontext.h> #include <ucontext.h>
...@@ -109,3 +111,4 @@ void native_cpu_init() ...@@ -109,3 +111,4 @@ void native_cpu_init()
makecontext(&native_context, sched_task_exit, 0); makecontext(&native_context, sched_task_exit, 0);
puts("RIOT native cpu initialized."); puts("RIOT native cpu initialized.");
} }
/** @} */
/** /**
* Native CPU rtc.h implementation * 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 * Copyright (C) 2013 Ludwig Ortmann
* *
* This file subject to the terms and conditions of the GNU General Public * 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. * License. See the file LICENSE in the top level directory for more details.
* *
* @ingroup arch
* @{
* @file
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de> * @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
* @} *
* @ingroup native_cpu
* @ingroup rtc
* @file
*/ */
#include <time.h> #include <time.h>
...@@ -22,47 +27,30 @@ ...@@ -22,47 +27,30 @@
static int native_rtc_enabled; static int native_rtc_enabled;
/**
* @brief Initializes the RTC for calendar mode
*/
void rtc_init(void) void rtc_init(void)
{ {
native_rtc_enabled = 0; native_rtc_enabled = 0;
printf("native rtc initialized\n"); printf("native rtc initialized\n");
} }
/**
* @brief Starts the RTC
*/
void rtc_enable(void) void rtc_enable(void)
{ {
DEBUG("rtc_enable\n"); DEBUG("rtc_enable\n");
native_rtc_enabled = 1; native_rtc_enabled = 1;
} }
/**
* @brief Stops the RTC
*/
void rtc_disable(void) void rtc_disable(void)
{ {
DEBUG("rtc_disable()\n"); DEBUG("rtc_disable()\n");
native_rtc_enabled = 0; 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) void rtc_set_localtime(struct tm* localt)
{ {
DEBUG("rtc_set_localtime()\n"); DEBUG("rtc_set_localtime()\n");
printf("setting time not supported."); 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) void rtc_get_localtime(struct tm* localt)
{ {
time_t t; time_t t;
......
...@@ -85,7 +85,7 @@ WARN_LOGFILE = ...@@ -85,7 +85,7 @@ WARN_LOGFILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the input files # configuration options related to the input files
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
INPUT = ../../core ../../cpu ../../board ../../sys src/ ../../drivers INPUT = ../../core ../../cpu ../../../boards ../../sys src/ ../../drivers
INPUT_ENCODING = UTF-8 INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.txt *.c *.h FILE_PATTERNS = *.txt *.c *.h
RECURSIVE = YES RECURSIVE = YES
......
...@@ -29,7 +29,7 @@ and the mailinglist (subscription via web site) ...@@ -29,7 +29,7 @@ and the mailinglist (subscription via web site)
/** /**
* @defgroup ltc4150 LTC4150 Coulomb Counter * @defgroup ltc4150 LTC4150 Coulomb Counter
* @ingroup coulomb * @ingroup drivers
* @{ * @{
*/ */
...@@ -48,11 +48,21 @@ and the mailinglist (subscription via web site) ...@@ -48,11 +48,21 @@ and the mailinglist (subscription via web site)
#define _R_SENSE (double)0.330 #define _R_SENSE (double)0.330
#define SUPPLY_VOLTAGE (5) #define SUPPLY_VOLTAGE (5)
/** board specific ltc4150 interrupt disable */
void ltc4150_disable_int(void); void ltc4150_disable_int(void);
/** board specific ltc4150 interrupt enable */
void ltc4150_enable_int(void); void ltc4150_enable_int(void);
/** board specific synchronization of ltc4150 */
void ltc4150_sync_blocking(void); void ltc4150_sync_blocking(void);
/** board specific ltc4150 initialization */
void ltc4150_arch_init(void); void ltc4150_arch_init(void);
/**
* ltc4150 interrupt handler,
* shall be called on ltc4150 interrupt,
* implemented in driver
*/
void ltc4150_interrupt(void); void ltc4150_interrupt(void);
/** @} */ /** * @} */
#endif /* __LTC4150_ARCH_H */ #endif /* __LTC4150_ARCH_H */
...@@ -24,6 +24,12 @@ and the mailinglist (subscription via web site) ...@@ -24,6 +24,12 @@ and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/ *******************************************************************************/
/**
* @defgroup rtc Realtime Clock
* @ingroup drivers
* @{
*/
#ifndef RTC_H #ifndef RTC_H
#define RTC_H #define RTC_H
...@@ -61,3 +67,4 @@ void rtc_get_localtime(struct tm* localt); ...@@ -61,3 +67,4 @@ void rtc_get_localtime(struct tm* localt);
extern int rtc_second_pid; extern int rtc_second_pid;
#endif #endif
/** @} */
...@@ -27,7 +27,7 @@ and the mailinglist (subscription via web site) ...@@ -27,7 +27,7 @@ and the mailinglist (subscription via web site)
/** /**
* @defgroup sht11 Sensirion SHT11 Driver * @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.
Please register or to comment