2013-09-13 20:45:33 +02:00
|
|
|
/****************************************************************************
|
2019-08-19 17:16:08 +02:00
|
|
|
* boards/arm/stm32/maple/src/stm32_leds.c
|
2013-09-13 20:45:33 +02:00
|
|
|
*
|
2021-08-16 10:30:10 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2013-09-13 20:45:33 +02:00
|
|
|
*
|
2021-08-16 10:30:10 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-09-13 20:45:33 +02:00
|
|
|
*
|
2021-08-16 10:30:10 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2013-09-13 20:45:33 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2015-02-28 01:49:24 +01:00
|
|
|
#include <nuttx/board.h>
|
2013-09-13 20:45:33 +02:00
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
|
|
|
#include "chip.h"
|
2020-05-01 03:20:29 +02:00
|
|
|
#include "arm_arch.h"
|
|
|
|
#include "arm_internal.h"
|
2013-09-13 20:45:33 +02:00
|
|
|
#include "stm32.h"
|
2015-12-29 22:44:56 +01:00
|
|
|
#include "maple.h"
|
2013-09-13 20:45:33 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static inline void set_led(bool v)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
ledinfo("Turn LED %s\n", v? "on":"off");
|
2013-09-13 20:45:33 +02:00
|
|
|
stm32_gpiowrite(GPIO_LED, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 16:03:01 +01:00
|
|
|
* Name: board_autoled_initialize
|
2013-09-13 20:45:33 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_LEDS
|
2015-11-01 16:03:01 +01:00
|
|
|
void board_autoled_initialize(void)
|
2013-09-13 20:45:33 +02:00
|
|
|
{
|
|
|
|
/* Configure LED GPIO for output */
|
|
|
|
|
|
|
|
stm32_configgpio(GPIO_LED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 16:07:36 +01:00
|
|
|
* Name: board_autoled_on
|
2013-09-13 20:45:33 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-11-01 16:07:36 +01:00
|
|
|
void board_autoled_on(int led)
|
2013-09-13 20:45:33 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
ledinfo("board_autoled_on(%d)\n", led);
|
2013-09-13 20:45:33 +02:00
|
|
|
switch (led)
|
|
|
|
{
|
|
|
|
case LED_STARTED:
|
|
|
|
case LED_HEAPALLOCATE:
|
|
|
|
/* As the board provides only one soft controllable LED, we simply turn
|
|
|
|
* it on when the board boots
|
|
|
|
*/
|
|
|
|
|
|
|
|
set_led(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PANIC:
|
2021-04-06 12:13:09 +02:00
|
|
|
|
2013-09-13 20:45:33 +02:00
|
|
|
/* For panic state, the LED is blinking */
|
|
|
|
|
|
|
|
set_led(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 16:10:08 +01:00
|
|
|
* Name: board_autoled_off
|
2013-09-13 20:45:33 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-11-01 16:10:08 +01:00
|
|
|
void board_autoled_off(int led)
|
2013-09-13 20:45:33 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
ledinfo("board_autoled_off(%d)\n", led);
|
2013-09-13 20:45:33 +02:00
|
|
|
|
|
|
|
switch (led)
|
|
|
|
{
|
|
|
|
case LED_STARTED:
|
|
|
|
case LED_PANIC:
|
2021-04-06 12:13:09 +02:00
|
|
|
|
2013-09-13 20:45:33 +02:00
|
|
|
/* For panic state, the LED is blinking */
|
|
|
|
|
|
|
|
set_led(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_ARCH_LEDS */
|