2016-08-27 18:04:34 -04:00
|
|
|
/*
|
2016-11-03 18:50:59 -04:00
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
2016-08-27 18:04:34 -04:00
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
2017-03-28 13:54:16 -04:00
|
|
|
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
2016-08-27 18:04:34 -04:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2017-08-25 22:17:07 -04:00
|
|
|
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H
|
|
|
|
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H
|
2016-11-03 18:50:59 -04:00
|
|
|
|
2017-04-12 18:24:50 -04:00
|
|
|
#include "common-hal/microcontroller/Pin.h"
|
2016-11-03 18:50:59 -04:00
|
|
|
|
2017-03-28 13:54:16 -04:00
|
|
|
#include "py/obj.h"
|
2016-11-03 18:50:59 -04:00
|
|
|
|
2017-03-28 13:54:16 -04:00
|
|
|
typedef struct {
|
|
|
|
mp_obj_base_t base;
|
2017-04-10 16:32:19 -04:00
|
|
|
uint8_t channel;
|
|
|
|
uint8_t pin;
|
2021-04-30 11:47:37 -04:00
|
|
|
uint16_t *buffer;
|
2017-04-10 16:32:19 -04:00
|
|
|
uint16_t maxlen;
|
|
|
|
bool idle_state;
|
|
|
|
volatile uint16_t start;
|
|
|
|
volatile uint16_t len;
|
|
|
|
volatile bool first_edge;
|
2020-03-13 20:21:15 -04:00
|
|
|
volatile uint32_t last_overflow;
|
|
|
|
volatile uint16_t last_count;
|
2018-06-05 15:38:31 -04:00
|
|
|
volatile bool errored_too_fast;
|
2017-04-10 16:32:19 -04:00
|
|
|
} pulseio_pulsein_obj_t;
|
|
|
|
|
|
|
|
void pulsein_reset(void);
|
2016-11-30 18:08:34 -05:00
|
|
|
|
2018-05-29 21:21:19 -04:00
|
|
|
void pulsein_interrupt_handler(uint8_t channel);
|
2020-03-13 20:21:15 -04:00
|
|
|
void pulsein_timer_interrupt_handler(uint8_t index);
|
2020-07-04 22:15:38 -04:00
|
|
|
#ifdef SAMD21
|
2021-04-20 16:21:05 -04:00
|
|
|
void rtc_start_pulse(void);
|
|
|
|
void rtc_end_pulse(void);
|
2020-07-04 22:15:38 -04:00
|
|
|
#endif
|
|
|
|
|
2018-05-29 21:21:19 -04:00
|
|
|
|
2017-08-25 22:17:07 -04:00
|
|
|
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H
|