2013-05-19 19:04:19 +02:00
|
|
|
/****************************************************************************
|
2019-08-19 17:16:08 +02:00
|
|
|
* boards/arm/stm32/stm32ldiscovery/src/stm32_userleds.c
|
2013-05-19 19:04:19 +02:00
|
|
|
*
|
2021-03-19 12:39:00 +01: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-05-19 19:04:19 +02:00
|
|
|
*
|
2021-03-19 12:39:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-05-19 19:04:19 +02:00
|
|
|
*
|
2021-03-19 12:39:00 +01: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-05-19 19:04:19 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
|
|
|
#include "chip.h"
|
|
|
|
#include "stm32.h"
|
|
|
|
#include "stm32ldiscovery.h"
|
|
|
|
|
|
|
|
#ifndef CONFIG_ARCH_LEDS
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 19:45:58 +01:00
|
|
|
* Name: board_userled_initialize
|
2013-05-19 19:04:19 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2020-06-05 12:08:02 +02:00
|
|
|
uint32_t board_userled_initialize(void)
|
2013-05-19 19:04:19 +02:00
|
|
|
{
|
|
|
|
/* Configure LED1-2 GPIOs for output */
|
|
|
|
|
|
|
|
stm32_configgpio(GPIO_LED1);
|
|
|
|
stm32_configgpio(GPIO_LED2);
|
2020-06-05 12:08:02 +02:00
|
|
|
return BOARD_NLEDS;
|
2013-05-19 19:04:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 19:45:58 +01:00
|
|
|
* Name: board_userled
|
2013-05-19 19:04:19 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-11-01 19:45:58 +01:00
|
|
|
void board_userled(int led, bool ledon)
|
2013-05-19 19:04:19 +02:00
|
|
|
{
|
2013-05-19 22:35:30 +02:00
|
|
|
uint32_t ledcfg;
|
2013-05-19 19:04:19 +02:00
|
|
|
|
|
|
|
if (led == BOARD_LED1)
|
|
|
|
{
|
|
|
|
ledcfg = GPIO_LED1;
|
|
|
|
}
|
2013-05-20 20:17:34 +02:00
|
|
|
else if (led == BOARD_LED2)
|
2013-05-19 19:04:19 +02:00
|
|
|
{
|
|
|
|
ledcfg = GPIO_LED2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stm32_gpiowrite(ledcfg, ledon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-01 19:45:58 +01:00
|
|
|
* Name: board_userled_all
|
2013-05-19 19:04:19 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2020-06-06 12:35:44 +02:00
|
|
|
void board_userled_all(uint32_t ledset)
|
2013-05-19 19:04:19 +02:00
|
|
|
{
|
|
|
|
bool ledon;
|
|
|
|
|
|
|
|
ledon = ((ledset & BOARD_LED1_BIT) != 0);
|
|
|
|
stm32_gpiowrite(GPIO_LED1, ledon);
|
|
|
|
|
|
|
|
ledon = ((ledset & BOARD_LED2_BIT) != 0);
|
|
|
|
stm32_gpiowrite(GPIO_LED2, ledon);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !CONFIG_ARCH_LEDS */
|