Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Added reference model for adding new keyboards.
Browse files Browse the repository at this point in the history
  • Loading branch information
humblehacker committed May 31, 2010
1 parent 930ae33 commit d190cdc
Show file tree
Hide file tree
Showing 48 changed files with 1,933 additions and 24 deletions.
40 changes: 40 additions & 0 deletions kb_reference/Board/Identifiers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
The HumbleHacker Keyboard Project
Copyright © 2008-2010, David Whetstone
david DOT whetstone AT humblehacker DOT com
This file is a part of The HumbleHacker Keyboard Project.
The HumbleHacker Keyboard Project is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
The HumbleHacker Keyboard Project 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 General
Public License for more details.
You should have received a copy of the GNU General Public License along
with The HumbleHacker Keyboard Project. If not, see
<http://www.gnu.org/licenses/>.
*/

#ifndef __IDENTIFIERS_H__
#define __IDENTIFIERS_H__

#define MANUFACTURER_NAME L"HumbleHacker.com"
#define MANUFACTURER_NAME_LEN USB_STRING_LEN(16)

#define PRODUCT_NAME L"HumbleHacked Reference Design"
#define PRODUCT_NAME_LEN USB_STRING_LEN(29)

#define SERIAL_NUMBER L"000000000000"
#define SERIAL_NUMBER_LEN USB_STRING_LEN(12)

#define VENDOR_ID 0x05AF
#define PRODUCT_ID 0x2031
#define RELEASE_NUMBER 0xF000

#endif // __IDENTIFIERS_H__
124 changes: 124 additions & 0 deletions kb_reference/Board/LEDs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
The HumbleHacker Keyboard Project
Copyright © 2008-2010, David Whetstone
david DOT whetstone AT humblehacker DOT com
This file is a part of the HumbleHacker Keyboard Firmware project.
The HumbleHacker Keyboard Project is free software: you can
redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
The HumbleHacker Keyboard Project 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with The HumbleHacker Keyboard Firmware project. If not, see
<http://www.gnu.org/licenses/>.
--------------------------------------------------------------------
This code is based on the LUFA library's LED driver stub, written
by Dean Camera.
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
--------------------------------------------------------------------
*/

#ifndef __LEDS_USER_H__
#define __LEDS_USER_H__
/* Includes: */
#include <avr/io.h>

// TODO: Add any required includes here

/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_LEDS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** LED mask for the first LED on the board. */
#define LEDS_LED1 (1<<0)

/** LED mask for the second LED on the board. */
#define LEDS_LED2 (1<<1)

/** LED mask for the third LED on the board. */
#define LEDS_LED3 (1<<2)

/** LED mask for the fourth LED on the board. */
#define LEDS_LED4 (1<<3)

/** LED mask for all the LEDs on the board. */
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)

/** LED mask for the none of the board LEDs */
#define LEDS_NO_LEDS 0

/** Keyboard specific LED mask names */
#define LED_NUM LEDS_LED1
#define LED_CAPS LEDS_LED2
#define LED_SCRL LEDS_LED3

/* Inline Functions: */
#if !defined(__DOXYGEN__)
static inline void LEDs_Init(void)
{
// Keyboard LEDs are F0-F3
DDRF |= LEDS_ALL_LEDS; // set pins as outputs
PORTF |= LEDS_ALL_LEDS; // set pins high to prevent sinking (lights off)
}

static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
PORTF &= ~LEDMask;
}

static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
PORTF |= LEDMask;
}

static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
PORTF = ((PORTF | LEDS_ALL_LEDS) & ~LEDMask);
}

static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
PORTF = ((PORTF | LEDMask) & ~ActiveMask);
}

static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
{
PORTF = (PORTF ^ (LEDMask & LEDS_ALL_LEDS));
}

static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t LEDs_GetLEDs(void)
{
return ~(PORTF & LEDS_ALL_LEDS);
}
#endif

/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif

#endif
File renamed without changes.
33 changes: 33 additions & 0 deletions kb_reference/layouts/Keyboard.kspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
The HumbleHacker Keyboard Project
Copyright � 2008-2010, David Whetstone
david DOT whetstone AT humblehacker DOT com

This file is a part of The HumbleHacker Keyboard Project.

The HumbleHacker Keyboard Project is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

The HumbleHacker Keyboard Project 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 General
Public License for more details.

You should have received a copy of the GNU General Public License along
with The HumbleHacker Keyboard Project. If not, see
<http://www.gnu.org/licenses/>.

*/

Keyboard:HumbleHackerReference rev:63

#include "Matrix.kspec"
#include "Map-Common.kspec"
#include "Map-US.kspec"
#include "Map-DV.kspec"
#include "Map-pDV.kspec"
#include "Map-JP.kspec"
#include "Map-Nm.kspec"
#include "Map-Fn.kspec"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
91 changes: 91 additions & 0 deletions kb_tm_prototype_2/conf_keyboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
The HumbleHacker Keyboard Project
Copyright © 2008-2010, David Whetstone
david DOT whetstone AT humblehacker DOT com
This file is a part of The HumbleHacker Keyboard Project.
The HumbleHacker Keyboard Project is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
The HumbleHacker Keyboard Project 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 General
Public License for more details.
You should have received a copy of the GNU General Public License along
with The HumbleHacker Keyboard Project. If not, see
<http://www.gnu.org/licenses/>.
*/

#ifndef __TYPEMATRIX_PROTOTYPE_2_H__
#define __TYPEMATRIX_PROTOTYPE_2_H__

// Rows are A0-A7
#define ROW_DDR DDRA
#define ROW_PORT PORTA
#define A_ROWS 0xff

// Columns are E0-E1, C0-C7, D0-D7
#define E_COLS ((1<<0)|(1<<1))
#define E_BITS 2
#define C_COLS 0xff
#define C_BITS 8
#define D_COLS 0xff

static inline
void activate_row(uint8_t row)
{
// Activate the current row
ROW_DDR = (1 << row); // set row as output
ROW_PORT = ~(1 << row); // row pin driven low
}

static inline
uint32_t
fix(uint32_t val)
{
// While wiring up the controller board, columns
// 7 & 9 and 10 & 12 were inadvertently transposed,
// so we put them back in their correct order here.

uint32_t bit7 = val & (1<<7);
uint32_t bit9 = val & (1<<9);
uint32_t bit10 = val & (1<<10);
uint32_t bit12 = val & (1<<12);

val &= ~((1<<12)|(1<<10)|(1<<9)|(1<<7));
val |= ((bit10<<2)|(bit12>>2)|(bit7<<2)|(bit9>>2));
return val;
}

static inline
uint32_t
read_row_data(void)
{
uint32_t result;
result = ((uint32_t)((~PINE)&E_COLS))
| ((uint32_t)((~PINC)&C_COLS)<<( E_BITS ))
| ((uint32_t)((~PIND)&D_COLS)<<( E_BITS+C_BITS ));
return fix(result);
}

static inline
void
init_cols(void)
{
/* Columns are inputs */
DDRE &= ~E_COLS;
DDRC = 0;
DDRD = 0;

/* Enable pull-up resistors on inputs */
PORTE |= E_COLS;
PORTC = C_COLS;
PORTD = D_COLS;
}

#endif // __TYPEMATRIX_PROTOTYPE_2_H__
Loading

0 comments on commit d190cdc

Please sign in to comment.