started work on lib/timer; and some housekeeping

partial-rewrite
Ben Blazak 2013-04-26 02:16:15 -07:00
parent 580c5e75a9
commit 20f9737b49
11 changed files with 86 additions and 16 deletions

View File

@ -69,7 +69,7 @@ KEYS__LAYER__NUM_POP(10);
#include "./common/matrix.h"
_layout_t _layout = {
static _layout_t _layout = {
// ............................................................................

View File

@ -104,7 +104,7 @@ typedef const _key_t _layout_t[][OPT__KB__ROWS][OPT__KB__COLUMNS];
/** variables/layout/description
* The variable containing our layout matrix
*/
_layout_t PROGMEM _layout;
static _layout_t PROGMEM _layout;
/** variables/sticky_key/description
* A pointer to the release function of the last sticky key pressed
@ -120,7 +120,7 @@ _layout_t PROGMEM _layout;
* directly before this was a sticky key as well, then the previous sticky
* key will never be released.
*/
void (*_sticky_key)(void);
static void (*_sticky_key)(void);
// ----------------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ KEYS__LAYER__NUM_POP(10);
#include "./common/matrix.h"
_layout_t _layout = {
static _layout_t _layout = {
// ............................................................................

View File

@ -65,7 +65,7 @@ KEYS__LAYER__NUM_POP(10);
#include "./common/matrix.h"
_layout_t _layout = {
static _layout_t _layout = {
// ............................................................................

View File

@ -37,9 +37,6 @@ CURDIRS := $(CURDIR) $(CURDIRS)
CURDIR := $(ROOTDIR)/lib/twi
include $(CURDIR)/options.mk
# -------
CURDIR := $(ROOTDIR)/lib/usb
include $(CURDIR)/options.mk
# -------
CURDIR := $(ROOTDIR)/lib/layout/eeprom-macro
include $(CURDIR)/options.mk
# -------

View File

@ -33,9 +33,9 @@ typedef struct {
uint8_t number; // layer-number
} element_t;
uint8_t _allocated = 0; // the number of positions allocated
uint8_t _filled = 0; // the number of positions filled
element_t * _stack = NULL; // (to be used as an array)
static uint8_t _allocated = 0; // the number of positions allocated
static uint8_t _filled = 0; // the number of positions filled
static element_t * _stack = NULL; // (to be used as an array)
// ----------------------------------------------------------------------------

View File

@ -7,6 +7,76 @@
/** description
* Implements the time defined in "../timer.h" for the ATMega32U4
*
* TODO: implement
* Prefix: `timer__`
*
* TODO: make sure this is how we want to do things...
* TODO: document and write header
* TODO: notes
* - it's unnecessary to keep 32 (or even 16) bit resolution if you don't need
* it; functions that don't should cast to uint8_t or uint16_t
* - use `end-start` for determining time difference. since the values are
* unsigned, this will work across overflows, for up to the maximum amount of
* time representable by the type you're using
* - `timer__init()` should be called once by `main()`
*/
#include <stdint.h>
#include <avr/interrupt.h>
// ----------------------------------------------------------------------------
static volatile uint32_t _milliseconds;
// ----------------------------------------------------------------------------
void timer__init(void) {
// /TODO
// references:
//
// Newbie's Guide to AVR Timers
// tutorial by Dean Camera
// http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106
//
// the atmega32u4 spec sheet
//
// the reference somewhere about what happens to unsigned things when
// negative values are assigned to them
// --- python3 ---
// >>> f_cpu = 16000000
// >>> .001/((1/f_cpu)*64)
// 250.00000000000003
// >>> (.001*f_cpu)/(64)
// 250.0
// ---------------
// table
// ------------------------------------------
// prescale value ticks per millisecond
// -------------- ---------------------
// 1 16000
// 8 2000
// 64 250
// 256 62.5
// 1024 15.625
// - we want a period = 1 millisecond = .001 seconds
// - cpu = 16 MHz; we can prescale at clk_io/64 to get 250 prescaled ticks
// per millisecond (which fits into a uint8_t, just barely)
//
// so we want to use TCCR0A, on the CTC (clear timer on compare match)
// mode, with compare interrupt enabled
}
uint32_t timer__get_milliseconds(void) {
return _milliseconds;
}
// ----------------------------------------------------------------------------
ISR(TIMER0_COMPA_vect) {
_milliseconds++;
}

View File

@ -7,7 +7,7 @@
## description
# timer options
#
# This file is meant to be included by the using '.../options.mk'
# This file is meant to be included by '.../firmware/makefile'
#

View File

@ -7,7 +7,7 @@
## description
# USB keyboard options
#
# This file is meant to be included by the using '.../options.mk'
# This file is meant to be included by '.../firmware/makefile'
#

View File

@ -38,8 +38,8 @@
// ----------------------------------------------------------------------------
bool _pressed_1[OPT__KB__ROWS][OPT__KB__COLUMNS];
bool _pressed_2[OPT__KB__ROWS][OPT__KB__COLUMNS];
static bool _pressed_1[OPT__KB__ROWS][OPT__KB__COLUMNS];
static bool _pressed_2[OPT__KB__ROWS][OPT__KB__COLUMNS];
bool (* is_pressed) [OPT__KB__ROWS][OPT__KB__COLUMNS] = &_pressed_1;
bool (* was_pressed) [OPT__KB__ROWS][OPT__KB__COLUMNS] = &_pressed_2;

View File

@ -48,6 +48,9 @@ CURDIR := $(ROOTDIR)/keyboard/$(KEYBOARD_NAME)
include $(CURDIR)/options.mk
# (the place for everything a keyboard implementation might want to change)
# -------
CURDIR := $(ROOTDIR)/lib/usb
include $(CURDIR)/options.mk
# -------
CURDIR := $(ROOTDIR)/lib/timer
include $(CURDIR)/options.mk
# -------