Skip to content

Commit

Permalink
Cosa.h - per-application customization for Cosa
Browse files Browse the repository at this point in the history
This commit introduces Cosa.h for per-application customization of Cosa and implements the first customizable value for maximum Event queue length.

Per-application customization is accomplished by copying cores/cosa/Cosa.h to the application directory and inserting relevant defines.
  • Loading branch information
jeditekunum committed Apr 17, 2015
1 parent 825937b commit d911dda
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
37 changes: 37 additions & 0 deletions cores/cosa/Cosa.h
@@ -0,0 +1,37 @@
/**
* @file Cosa.h
* @version 1.0
*
* @section License
* Copyright (C) 2015, Mikael Patel
*
* 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.
*
* @section Description
* Default for per-application customization of Cosa.
*
* This file is part of the Arduino Che Cosa project.
*/

#ifndef COSA_H
#define COSA_H

/* This file is intentionally empty as it is the default customization
* if the application does not provide one.
*
* To customize Cosa, copy this file into the application directory
* and place defines in it.
*
* The Cosa standard naming convention for customization defines
* is COSA_class_parameter. For example, COSA_EVENT_QUEUE_MAX.
*/

#endif
15 changes: 10 additions & 5 deletions cores/cosa/Cosa/Event.hh
Expand Up @@ -24,6 +24,14 @@
#include "Cosa/Types.h"
#include "Cosa/Queue.hh"

#ifndef COSA_EVENT_QUEUE_MAX
#if defined(BOARD_ATTINY)
#define COSA_EVENT_QUEUE_MAX 8
#else
#define COSA_EVENT_QUEUE_MAX 16
#endif
#endif

/**
* Event data structure with type, source and value.
*/
Expand All @@ -33,11 +41,8 @@ public:
* Size of event queue. Adjust depending on application. Must be
* Power(2).
*/
#if defined(BOARD_ATTINY)
static const uint8_t QUEUE_MAX = 8;
#else
static const uint8_t QUEUE_MAX = 16;
#endif
static const uint8_t QUEUE_MAX = COSA_EVENT_QUEUE_MAX;

/**
* Event types are added here. Typical mapping from interrupts to
* events. Note that the event is not a global numbering
Expand Down
1 change: 1 addition & 0 deletions cores/cosa/Cosa/Types.h
Expand Up @@ -39,6 +39,7 @@

#include "Cosa/Errno.h"
#include "Cosa/Board.hh"
#include "Cosa.h"

/**
* Number of bits in a character.
Expand Down

0 comments on commit d911dda

Please sign in to comment.