2015-02-05 20:51:32 +01:00
|
|
|
/****************************************************************************
|
2019-08-16 15:40:59 +02:00
|
|
|
* boards/arm/tiva/tm4c123g-launchpad/src/tm4c_timer.c
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
2021-08-16 10:46:38 +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
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
2021-08-16 10:46:38 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
2021-08-16 10:46:38 +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.
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include "tiva_timer.h"
|
|
|
|
#include "tm4c123g-launchpad.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_TIVA_TIMER
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-04-08 17:15:17 +02:00
|
|
|
* Pre-processor Definitions
|
2015-02-05 20:51:32 +01:00
|
|
|
****************************************************************************/
|
2019-08-16 15:40:59 +02:00
|
|
|
|
2015-02-05 20:51:32 +01:00
|
|
|
/* Configuration ************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_TIVA_TIMER32_PERIODIC
|
|
|
|
# error CONFIG_TIVA_TIMER32_PERIODIC is not defined
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2016-05-23 16:26:46 +02:00
|
|
|
* Name: tiva_timer_configure
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2015-03-23 17:05:50 +01:00
|
|
|
* Configure the timer driver for the timer example application.
|
2015-02-05 20:51:32 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-05-23 16:26:46 +02:00
|
|
|
int tiva_timer_configure(void)
|
2015-02-05 20:51:32 +01:00
|
|
|
{
|
2015-03-23 17:05:50 +01:00
|
|
|
static bool initialized = false;
|
|
|
|
int ret = OK;
|
2015-02-05 20:51:32 +01:00
|
|
|
|
2015-03-23 17:05:50 +01:00
|
|
|
/* Check if we have already initialized */
|
2015-02-05 20:51:32 +01:00
|
|
|
|
2015-03-23 17:05:50 +01:00
|
|
|
if (!initialized)
|
2015-02-05 20:51:32 +01:00
|
|
|
{
|
2015-03-23 17:05:50 +01:00
|
|
|
struct tiva_gptm32config_s timer_config;
|
|
|
|
timer_config.cmn.gptm = 0;
|
|
|
|
timer_config.cmn.mode = TIMER32_MODE_PERIODIC;
|
|
|
|
timer_config.cmn.alternate = false;
|
|
|
|
|
|
|
|
timer_config.config.flags = TIMER_FLAG_COUNTUP;
|
|
|
|
timer_config.config.handler = 0;
|
|
|
|
timer_config.config.arg = 0;
|
|
|
|
|
2019-08-16 15:40:59 +02:00
|
|
|
ret = tiva_timer_initialize(CONFIG_EXAMPLES_TIMER_DEVNAME,
|
|
|
|
&timer_config);
|
2015-03-23 17:05:50 +01:00
|
|
|
if (ret < 0)
|
2019-08-16 15:40:59 +02:00
|
|
|
{
|
|
|
|
syslog(LOG_ERR, "ERROR: Failed to register timer driver: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
2015-03-23 17:05:50 +01:00
|
|
|
|
|
|
|
/* now we are initialized */
|
|
|
|
|
|
|
|
initialized = true;
|
2015-02-05 20:51:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_TIVA_TIMER */
|