mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-07 16:11:43 +00:00
This is a straightforward conversion of existing tables into X-Macro style definitions for the GPIO alternate functions. This change in itself, is not particularly powerful, but having all GPIO settings in a single file makes a board easier to understand. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Followed by manual testing of interrupt on change and UART functionality on STM32F0 based discovery board. Change-Id: Ib7f1f014f4bd289d7c0ac3100470ba2dc71ca579 Reviewed-on: https://chromium-review.googlesource.com/207987 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
74 lines
1.6 KiB
C
74 lines
1.6 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"
|
|
|
|
/* 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);
|