Alin Jerpelea 7689392528 author: Zilogic Systems: update licenses to Apache
Gregory Nutt has submitted the SGA

Zilogic Systems has submitted the SGA

Uniquix Tecnologia has submitted the SGA

Michael Jung has submitted the ICLA

Alan Carvalho de Assis has submitted the ICLA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-07-19 03:08:00 -07:00

90 lines
2.6 KiB
C

/****************************************************************************
* boards/arm/lpc43xx/lpc4370-link2/src/lpc43_adc.c
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "lpc43_adc.h"
#if defined(CONFIG_LPC43_ADC0) || defined(CONFIG_LPC43_ADC1)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: lpc43_adc_setup
*
* Description:
* Initialize ADC and register the ADC driver.
*
****************************************************************************/
int lpc43_adc_setup(void)
{
static bool initialized = false;
struct adc_dev_s *adc;
int ret;
/* Check if we have already initialized */
if (!initialized)
{
/* Call lpc43_adcinitialize() to get an instance of the ADC interface */
adc = lpc43_adcinitialize();
if (adc == NULL)
{
aerr("ERROR: Failed to get ADC interface\n");
return -ENODEV;
}
/* Register the ADC driver at "/dev/adc0" */
ret = adc_register("/dev/adc0", adc);
if (ret < 0)
{
aerr("ERROR: adc_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_ADC */