mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 01:21:49 +00:00
Previously each board.h and board.c contained an enum and an array for gpio definitons that had to be manually kept in sync, with no compiler assistance other than that their lengths matched. This change adds a single gpio.inc file that declares all gpio's that a board uses and is used as an X-macro include file to generate both the gpio_signal enum and the gpio_list array. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Change-Id: If9c9feca968619a59ff9f20701359bcb9374e4da Reviewed-on: https://chromium-review.googlesource.com/205354 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
80 lines
1.8 KiB
C
80 lines
1.8 KiB
C
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
/* IT8380 development board configuration */
|
|
|
|
#include "common.h"
|
|
#include "console.h"
|
|
#include "gpio.h"
|
|
#include "hooks.h"
|
|
#include "registers.h"
|
|
#include "task.h"
|
|
#include "util.h"
|
|
|
|
/* Test GPIO interrupt function that toggles one LED. */
|
|
void test_interrupt(enum gpio_signal signal)
|
|
{
|
|
static int busy_state;
|
|
|
|
/* toggle LED */
|
|
busy_state = !busy_state;
|
|
gpio_set_level(GPIO_BUSY_LED, busy_state);
|
|
}
|
|
|
|
#include "gpio_list.h"
|
|
|
|
/* Pins with alternate functions */
|
|
const struct gpio_alt_func gpio_alt_funcs[] = {
|
|
{GPIO_B, 0x03, 1, MODULE_UART, GPIO_PULL_UP}, /* UART0 */
|
|
};
|
|
const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
|
|
|
|
/* Initialize board. */
|
|
static void board_init(void)
|
|
{
|
|
gpio_enable_interrupt(GPIO_START_SW);
|
|
}
|
|
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|
|
|
|
/*****************************************************************************/
|
|
/* Console commands */
|
|
|
|
void display_7seg(uint8_t val)
|
|
{
|
|
int i;
|
|
static const uint8_t digits[16] = {
|
|
0xc0, 0xf9, 0xa8, 0xb0,
|
|
0x99, 0x92, 0x82, 0xf8,
|
|
0x80, 0x98, 0x88, 0x83,
|
|
0xc6, 0xa1, 0x86, 0x8e,
|
|
};
|
|
|
|
for (i = 0; i < 7; i++)
|
|
gpio_set_level(GPIO_H_LED0 + i, digits[val >> 4] & (1 << i));
|
|
for (i = 0; i < 7; i++)
|
|
gpio_set_level(GPIO_L_LED0 + i, digits[val & 0xf] & (1 << i));
|
|
}
|
|
|
|
static int command_7seg(int argc, char **argv)
|
|
{
|
|
uint8_t val;
|
|
char *e;
|
|
|
|
if (argc != 2)
|
|
return EC_ERROR_PARAM_COUNT;
|
|
|
|
val = strtoi(argv[1], &e, 16);
|
|
if (*e)
|
|
return EC_ERROR_PARAM1;
|
|
|
|
ccprintf("display 0x%02x\n", val);
|
|
display_7seg(val);
|
|
|
|
return EC_SUCCESS;
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(seg7, command_7seg,
|
|
"<hex>",
|
|
"Print 8-bit value on 7-segment display",
|
|
NULL);
|