working on nrf52

This commit is contained in:
hathach
2018-03-13 16:30:53 +07:00
parent 2435abb0a8
commit ffca1f5e64
20 changed files with 186 additions and 100 deletions

View File

@@ -1,63 +0,0 @@
/**************************************************************************/
/*!
@file board.c
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#include "board.h"
//#include "app_os_prio.h"
#if TUSB_CFG_OS == TUSB_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler (void)
{
system_ticks++;
}
uint32_t tusb_hal_tick_get(void)
{
return system_ticks;
}
#endif
// TODO remove legacy cmsis code
void check_failed(uint8_t *file, uint32_t line)
{
(void) file;
(void) line;
}

View File

@@ -131,13 +131,21 @@
/// Initialize all required peripherals on board including uart, led, buttons etc ...
void board_init(void);
/** \brief Turns on and off leds on the board
* \param[in] on_mask Bitmask for LED's numbers is turning ON
* \param[out] off_mask Bitmask for LED's numbers is turning OFF
* \note the \a on_mask is more priority then \a off_mask, if an led's number is present on both.
* It will be turned ON.
*/
void board_leds(uint32_t on_mask, uint32_t off_mask);
#define BOARD_LED0 0
void board_led_control(uint32_t led_id, bool state);
static inline void board_led_on(uint32_t led_id)
{
board_led_control(led_id, true);
}
static inline void board_led_off(uint32_t led_id)
{
board_led_control(led_id, false);
}
/** \brief Get the current state of the buttons on the board
* \return Bitmask where a '1' means active (pressed), a '0' means inactive.
@@ -156,19 +164,6 @@ void board_uart_putchar(uint8_t c);
/** @} */
#if 0
//------------- Board Application -------------//
void led_blinking_task(void* param);
/// Initialize the LED blinking task application. The initial blinking rate is 1 Hert (1 per second)
void led_blinking_init(void);
/** \brief Change the blinking rate.
* \param[in] ms The interval between on and off.
*/
void led_blinking_set_interval(uint32_t ms);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -116,9 +116,11 @@ void board_init(void)
//--------------------------------------------------------------------+
// LEDS
//--------------------------------------------------------------------+
void board_leds(uint32_t on_mask, uint32_t off_mask)
void board_led_control(uint32_t id, bool state)
{
pca9532_setLeds( on_mask << 8, off_mask << 8);
uint16_t on_mask = state ? (1 << id) : 0;
uint16_t off_mask = state ? 0 : (1 << id);
pca9532_setLeds( on_mask << 8, off_mask << 8 );
}
//--------------------------------------------------------------------+

View File

@@ -53,6 +53,8 @@
#include "oem_base_board/pca9532.h" // LEDs
#define BOARD_LED_NUM 1
//#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
#define CFG_PRINTF_TARGET PRINTF_TARGET_UART

View File

@@ -43,6 +43,7 @@
*------------------------------------------------------------------*/
#define LED_1 13
#define LED_STATE_ON 0
#define LED_STATE_OFF (1-LED_STATE_ON)
/*------------------------------------------------------------------*/
@@ -60,17 +61,10 @@ void board_init(void)
NVIC_EnableIRQ(SysTick_IRQn);
}
void board_leds(uint32_t on_mask, uint32_t off_mask)
void board_led_control(uint32_t led_id, bool state)
{
if (on_mask)
{
nrf_gpio_pin_write(LED_1, LED_STATE_ON);
}
if ( off_mask)
{
nrf_gpio_pin_write(LED_1, 1-LED_STATE_ON);
}
(void) led_id;
nrf_gpio_pin_write(LED_1, state ? LED_STATE_ON : LED_STATE_OFF);
}
uint32_t board_buttons(void)

View File

@@ -42,6 +42,7 @@
extern "C" {
#endif
#define BOARD_LED_NUM 1
#ifdef __cplusplus
}