MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
pt.h
1 
6 /* *****************************************************************************
7  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains allts
35  * ownership rights.
36  *
37  ***************************************************************************** */
38 
39 /* Define to prevent redundant inclusion */
40 #ifndef _MXC_PT_H_
41 #define _MXC_PT_H_
42 
43 /* **** Includes **** */
44 
45 #include "gcr_regs.h"
46 #include "pt_regs.h"
47 #include "ptg_regs.h"
48 #include "mxc_device.h"
49 #include "mxc_errors.h"
50 #include "mxc_assert.h"
51 #include "mxc_sys.h"
52 #include "mcr_regs.h"
53 #include <stdio.h>
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
70 typedef struct {
71  unsigned channel;
72  uint32_t bps;
73  uint32_t pattern;
74  uint8_t ptLength;
75  uint16_t loop;
76  uint16_t loopDelay;
77 } mxc_pt_cfg_t;
78 
82 typedef enum {
83  MXC_PT_CLK_DIV1,
84  MXC_PT_CLK_DIV2,
85  MXC_PT_CLK_DIV4,
86  MXC_PT_CLK_DIV8,
87  MXC_PT_CLK_DIV16,
88  MXC_PT_CLK_DIV32,
89  MXC_PT_CLK_DIV64,
90  MXC_PT_CLK_DIV128,
92 
101 
113 void MXC_PT_Shutdown (mxc_ptg_regs_t *ptg, uint32_t pts);
114 
129 
141 int MXC_PT_SqrWaveConfig (mxc_ptg_regs_t *ptg, unsigned channel, uint32_t freq);
142 
149 void MXC_PT_Start (mxc_ptg_regs_t *ptg, unsigned pts);
150 
157 void MXC_PT_Stop (mxc_ptg_regs_t *ptg, unsigned pts);
158 
169 uint32_t MXC_PT_IsActive (mxc_ptg_regs_t *ptg, uint32_t pts);
170 
178 void MXC_PT_SetPattern (unsigned pts, uint32_t pattern);
179 
189 void MXC_PT_EnableInt (mxc_ptg_regs_t *ptg, uint32_t pts);
190 
200 void MXC_PT_DisableInt (mxc_ptg_regs_t *ptg, uint32_t pts);
201 
211 
218 void MXC_PT_ClearFlags (mxc_ptg_regs_t *ptg, uint32_t flags);
219 
229 void MXC_PT_EnableRestart (unsigned start, unsigned stop, uint8_t restartIndex);
230 
237 void MXC_PT_DisableRestart (unsigned channel, uint8_t restartIndex);
238 
247 void MXC_PT_Resync (mxc_ptg_regs_t *ptg, uint32_t pts);
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif /* _MXC_PT_H_ */
MXC_PT_Init
void MXC_PT_Init(mxc_ptg_regs_t *ptg, mxc_clk_scale_t clk_scale)
This function initializes the pulse trains to a known stopped state and sets the global PT clock scal...
MXC_PT_Resync
void MXC_PT_Resync(mxc_ptg_regs_t *ptg, uint32_t pts)
Resynchronize individual pulse trains together. Resync will stop those resync_pts; others will be sti...
mxc_pt_cfg_t
Structure type for pulse train mode configuration.
Definition: pt.h:70
MXC_PT_GetFlags
uint32_t MXC_PT_GetFlags(mxc_ptg_regs_t *ptg)
Gets the pulse trains's interrupt flags.
mxc_pt_cfg_t::ptLength
uint8_t ptLength
Number of bits in pulse train, 0 = 32bits, 1 = non valid , 2 = 2 bits, ...
Definition: pt.h:74
MXC_PT_Stop
void MXC_PT_Stop(mxc_ptg_regs_t *ptg, unsigned pts)
Stops pulse trains.
mxc_ptg_regs_t
Definition: ptg_regs.h:88
MXC_PT_Config
int MXC_PT_Config(mxc_ptg_regs_t *ptg, mxc_pt_cfg_t *cfg)
Configures the pulse train in the specified mode.
mxc_pt_cfg_t::pattern
uint32_t pattern
Output pattern to shift out, starts at LSB.
Definition: pt.h:73
MXC_PT_SqrWaveConfig
int MXC_PT_SqrWaveConfig(mxc_ptg_regs_t *ptg, unsigned channel, uint32_t freq)
Configures the pulse train in the square wave mode.
MXC_PT_SetPattern
void MXC_PT_SetPattern(unsigned pts, uint32_t pattern)
Sets the pattern of the pulse train.
MXC_PT_EnableInt
void MXC_PT_EnableInt(mxc_ptg_regs_t *ptg, uint32_t pts)
Enable interrupts for the pulse trains selected.
MXC_PT_ClearFlags
void MXC_PT_ClearFlags(mxc_ptg_regs_t *ptg, uint32_t flags)
Clears the pulse train's interrupt flag.
mxc_clk_scale_t
mxc_clk_scale_t
Enumeration type for the system clock scale types.
Definition: pt.h:82
MXC_PT_IsActive
uint32_t MXC_PT_IsActive(mxc_ptg_regs_t *ptg, uint32_t pts)
Determines if the pulse trains selected are running.
MXC_PT_DisableRestart
void MXC_PT_DisableRestart(unsigned channel, uint8_t restartIndex)
Disable the restart for the specified pulse train.
mxc_pt_cfg_t::channel
unsigned channel
PT Channel to use.
Definition: pt.h:71
MXC_PT_Shutdown
void MXC_PT_Shutdown(mxc_ptg_regs_t *ptg, uint32_t pts)
Shutdown the pulse train channel/channels.
MXC_PT_DisableInt
void MXC_PT_DisableInt(mxc_ptg_regs_t *ptg, uint32_t pts)
Disable interrupts for the pulse trains selected.
MXC_PT_EnableRestart
void MXC_PT_EnableRestart(unsigned start, unsigned stop, uint8_t restartIndex)
Setup and enables a pulse train to restart after another pulse train has exited its loop....
MXC_PT_Start
void MXC_PT_Start(mxc_ptg_regs_t *ptg, unsigned pts)
Starts the pulse trains specified.
mxc_pt_cfg_t::loopDelay
uint16_t loopDelay
Delay between loops specified in bits Example: loopDelay = 4, delays time = time it takes to shift ou...
Definition: pt.h:76
mxc_pt_cfg_t::loop
uint16_t loop
Number of times to repeat the train, 0 = continuous.
Definition: pt.h:75
mxc_pt_cfg_t::bps
uint32_t bps
pulse train bit rate
Definition: pt.h:72