Skip to content

Commit

Permalink
Merge pull request #1 from antoinealb/hardware_abstraction
Browse files Browse the repository at this point in the history
Started working on a HAL.
  • Loading branch information
antoinealb committed Mar 18, 2014
2 parents 649b7a8 + bc87321 commit c18d2e8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
19 changes: 0 additions & 19 deletions include/aversive.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@

#include <inttypes.h>

#ifdef COMPILE_ON_ROBOT

#include "os_cpu.h"
#include "os_cfg.h"
#include "ucos_ii.h"
#include <system.h>
#include <io.h>
#include <sys/alt_irq.h>
#include <aversive/error.h>

#else /* Workaround to compile on X86. */

/** Reimplementation de IORD du NIOS2 pour compiler sur le PC */
#define IORD(adress, offset) (*((int32_t *)adress+offset))
/** Reimplementation de IOWR du NIOS2 pour compiler sur le PC */
#define IOWR(adress, offset, data) (*((int32_t *)adress+offset) = data)
#endif


/** @brief Computes the absolute value of a number
*
* While the abs() function in the libc works only with int type
Expand Down
17 changes: 17 additions & 0 deletions modules/platform/platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _PLATFORM_H_
#define _PLATFORM_H_

#ifdef COMPILE_ON_ROBOT
#include <platform/platform_nios2.h>
#else
#include <platform/platform_host.h>
#endif

/** @brief Resets the boards. */
void reset(void);

/** @brief Called after a non recoverable error. */
void panic(void);


#endif
10 changes: 10 additions & 0 deletions modules/platform/platform_host.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _PLATFORM_HOST_H
#define _PLATFORM_HOST_H

/** Reimplementation de IORD du NIOS2 pour compiler sur le PC */
#define IORD(adress, offset) (*((int32_t *)adress+offset))

/** Reimplementation de IOWR du NIOS2 pour compiler sur le PC */
#define IOWR(adress, offset, data) (*((int32_t *)adress+offset) = data)

#endif
12 changes: 12 additions & 0 deletions modules/platform/platform_nios2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _PLATFORM_NIOS2_H_
#define _PLATFORM_NIOS2_H_

#include "os_cpu.h"
#include "os_cfg.h"
#include "ucos_ii.h"
#include <system.h>
#include <io.h>
#include <sys/alt_irq.h>
#include <aversive/error.h>

#endif

0 comments on commit c18d2e8

Please sign in to comment.