Christina Quast | 637ace9 | 2014-11-28 13:28:37 +0100 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------------
|
| 2 | * ATMEL Microcontroller Software Support
|
| 3 | * ----------------------------------------------------------------------------
|
| 4 | * Copyright (c) 2010, Atmel Corporation
|
| 5 | *
|
| 6 | * All rights reserved.
|
| 7 | *
|
| 8 | * Redistribution and use in source and binary forms, with or without
|
| 9 | * modification, are permitted provided that the following conditions are met:
|
| 10 | *
|
| 11 | * - Redistributions of source code must retain the above copyright notice,
|
| 12 | * this list of conditions and the disclaimer below.
|
| 13 | *
|
| 14 | * Atmel's name may not be used to endorse or promote products derived from
|
| 15 | * this software without specific prior written permission.
|
| 16 | *
|
| 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
| 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
| 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
| 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
| 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 27 | * ----------------------------------------------------------------------------
|
| 28 | */
|
| 29 |
|
| 30 | /**
|
| 31 | * \page sam3s_ppc SAM3S PIO Parallel Capture
|
| 32 | *
|
| 33 | * \section Purpose
|
| 34 | *
|
| 35 | * Interface for configuration the PIO Parallel Capture peripheral.
|
| 36 | *
|
| 37 | * \section Usage
|
| 38 | *
|
| 39 | * -# Configurate the interrupt for PIOA, can be done by PIO_InitializeInterrupts()
|
| 40 | * -# Initialize the PIO Parallel Capture API by filing the SpioCaptureInit structur.
|
| 41 | * 2 options:
|
| 42 | * - alwaysSampling: for sample data with or without take in account ENABLE pins.
|
| 43 | * - halfSampling: for sample all data or only one time out of two
|
| 44 | * -# Call PIO_CaptureInit() for init and enable the PDC, init the PIO capture.
|
| 45 | * -# Call PIO_CaptureEnable() for enable the PIO Parallel Capture.
|
| 46 | * -# When an interrupt is received, the PIO_CaptureHandler() is call and the respective
|
| 47 | * callback is launch.
|
| 48 | * -# When the transfer is complete, the user need to disable interrupt with
|
| 49 | * PIO_CaptureDisableIt(). Otherway, the PDC will send an interrupt.
|
| 50 | * -# The data receive by the PIO Parallel Capture is inside the buffer passed in the
|
| 51 | * PIO_CaptureInit().
|
| 52 | *
|
| 53 | */
|
| 54 |
|
| 55 | #ifndef PIO_CAPTURE_H
|
| 56 | #define PIO_CAPTURE_H
|
| 57 |
|
| 58 | /*----------------------------------------------------------------------------
|
| 59 | * Types
|
| 60 | *----------------------------------------------------------------------------*/
|
| 61 |
|
| 62 | /** \brief PIO Parallel Capture structure for initialize.
|
| 63 | *
|
| 64 | * At the end of the transfer, the callback is invoked by the interrupt handler.
|
| 65 | */
|
| 66 | typedef struct _SpioCaptureInit {
|
| 67 |
|
| 68 | /** PIO_PCRHR register is a BYTE, HALF-WORD or WORD */
|
| 69 | uint8_t dsize;
|
| 70 | /** PDC size, data to be received */
|
| 71 | uint16_t dPDCsize;
|
| 72 | /** Data to be received */
|
| 73 | uint32_t *pData;
|
| 74 | /** Parallel Capture Mode Always Sampling */
|
| 75 | uint8_t alwaysSampling;
|
| 76 | /** Parallel Capture Mode Half Sampling */
|
| 77 | uint8_t halfSampling;
|
| 78 | /** Parallel Capture Mode First Sample */
|
| 79 | uint8_t modeFirstSample;
|
| 80 | /** Callback function invoked at Mode Data Ready */
|
| 81 | void (*CbkDataReady)( struct _SpioCaptureInit* );
|
| 82 | /** Callback function invoked at Mode Overrun Error */
|
| 83 | void (*CbkOverrun)( struct _SpioCaptureInit* );
|
| 84 | /** Callback function invoked at End of Reception Transfer */
|
| 85 | void (*CbkEndReception)( struct _SpioCaptureInit* );
|
| 86 | /** Callback function invoked at Reception Buffer Full */
|
| 87 | void (*CbkBuffFull)( struct _SpioCaptureInit* );
|
| 88 | /** Callback arguments.*/
|
| 89 | void *pParam;
|
| 90 |
|
| 91 | } SpioCaptureInit ;
|
| 92 |
|
| 93 |
|
| 94 | /*----------------------------------------------------------------------------
|
| 95 | * Global Functions
|
| 96 | *----------------------------------------------------------------------------*/
|
| 97 | extern void PIO_CaptureDisableIt( uint32_t itToDisable ) ;
|
| 98 | extern void PIO_CaptureEnableIt( uint32_t itToEnable ) ;
|
| 99 | extern void PIO_CaptureEnable( void ) ;
|
| 100 | extern void PIO_CaptureDisable( void ) ;
|
| 101 | extern void PIO_CaptureInit( SpioCaptureInit* pInit ) ;
|
| 102 |
|
| 103 | #endif /* #ifndef PIO_CAPTURE_H */
|
| 104 |
|