Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / system / ports / src / sys_ports_static.c @ eaef5bd1

History | View | Annotate | Download (25.4 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  SYS PORTS Static Functions for PORTS System Service
4

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    sys_ports_static.c
10

11
  Summary:
12
    SYS PORTS static function implementations for the Ports System Service.
13

14
  Description:
15
    The Ports System Service provides a simple interface to manage the ports
16
    on Microchip microcontrollers. This file defines the static implementation for the 
17
    Ports System Service.
18
    
19
  Remarks:
20
    Static functions incorporate all system ports configuration settings as
21
    determined by the user via the Microchip Harmony Configurator GUI.  It provides 
22
    static version of the routines, eliminating the need for an object ID or 
23
    object handle.
24

25
*******************************************************************************/
26

    
27
//DOM-IGNORE-BEGIN
28
/*******************************************************************************
29
Copyright (c) 2013 released Microchip Technology Inc.  All rights reserved.
30

31
Microchip licenses to you the right to use, modify, copy and distribute
32
Software only when embedded on a Microchip microcontroller or digital signal
33
controller that is integrated into your product or third party product
34
(pursuant to the sublicense terms in the accompanying license agreement).
35

36
You should refer to the license agreement accompanying this Software for
37
additional information regarding your rights and obligations.
38

39
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
40
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
41
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
42
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
43
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
44
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
45
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
46
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
47
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
48
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
49
*******************************************************************************/
50
//DOM-IGNORE-END
51

    
52
#include "system_config.h"
53
#include "system/ports/sys_ports.h"
54
#include "peripheral/devcon/plib_devcon.h"
55
#include "peripheral/ports/plib_ports.h"
56
#include "peripheral/int/plib_int.h"
57

    
58
/******************************************************************************
59
  Function:
60
    SYS_PORTS_Initialize(void)
61

62
  Summary:
63
    Initializes Ports System Service
64

65
  Description:
66
    This function initializes different port pins/channels to the desired state.
67
    It also remaps the pins to the desired specific function.
68

69
  Remarks:
70
    None.
71
*/
72
void SYS_PORTS_Initialize(void)
73
{
74
    /* AN and CN Pins Initialization */
75
    PLIB_PORTS_AnPinsModeSelect(PORTS_ID_0, SYS_PORT_AD1PCFG, PORTS_PIN_MODE_DIGITAL);
76
    PLIB_PORTS_CnPinsPullUpEnable(PORTS_ID_0, SYS_PORT_CNPUE);
77
    PLIB_PORTS_CnPinsEnable(PORTS_ID_0, SYS_PORT_CNEN);
78
    PLIB_PORTS_ChangeNoticeEnable(PORTS_ID_0);
79

    
80
    PLIB_PORTS_Read(PORTS_ID_0, PORT_CHANNEL_D);    
81
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);         
82
    PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);
83
    PLIB_INT_VectorPrioritySet(INT_ID_0, INT_VECTOR_CN, INT_PRIORITY_LEVEL2);
84
    PLIB_INT_VectorSubPrioritySet(INT_ID_0, INT_VECTOR_CN, INT_SUBPRIORITY_LEVEL0);          
85
    
86
    
87
    /* PORT D Initialization */
88
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ODC);
89
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_LAT);
90
        PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_TRIS ^ 0xFFFF);
91
    
92
}
93

    
94
/******************************************************************************
95
  Function:
96
    PORTS_DATA_TYPE SYS_PORTS_Read( PORTS_MODULE_ID index, PORTS_CHANNEL channel )
97

98
  Summary:
99
    Reads the data from the I/O port.
100

101
  Description:
102
    This function reads the data from the I/O port.
103

104
  Remarks:
105
    None.
106
*/
107

    
108
PORTS_DATA_TYPE SYS_PORTS_Read( PORTS_MODULE_ID index, PORTS_CHANNEL channel )
109
{
110
    return PLIB_PORTS_Read( index, channel );
111
}
112

    
113

    
114
/******************************************************************************
115
  Function:
116
    void SYS_PORTS_Write( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
117
                                      PORTS_DATA_TYPE value )
118

119
  Summary:
120
    Writes the data from the I/O port.
121

122
  Description:
123
    This function writes the data to the I/O port.
124

125
  Remarks:
126
    None.
127
*/
128

    
129
void SYS_PORTS_Write( PORTS_MODULE_ID index,
130
                      PORTS_CHANNEL channel,
131
                      PORTS_DATA_TYPE value )
132
{
133
    PLIB_PORTS_Write( index, channel, value );
134
}
135

    
136

    
137
/******************************************************************************
138
  Function:
139
    void SYS_PORTS_Set( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
140
                                 PORTS_DATA_TYPE value,
141
                         PORTS_DATA_MASK mask )
142

143
  Summary:
144
    Sets the selected digital port/latch based on the mask.
145

146
  Description:
147
    This function sets the selected digital port/latch relative to the mask.
148

149
  Remarks:
150
    None.
151
*/
152

    
153
void SYS_PORTS_Set( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
154
                    PORTS_DATA_TYPE value,
155
                    PORTS_DATA_MASK mask )
156
{
157
    PLIB_PORTS_Set( index, channel, value, mask );
158
}
159

    
160

    
161
/******************************************************************************
162
  Function:
163
    void SYS_PORTS_Clear ( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
164
                           PORTS_DATA_MASK clearMask )
165

166
  Summary:
167
    Clears the selected digital port.
168

169
  Description:
170
    This function clears the selected digital port.
171

172
  Remarks:
173
    None.
174
*/
175

    
176
void SYS_PORTS_Clear ( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
177
                           PORTS_DATA_MASK clearMask )
178
{
179
    PLIB_PORTS_Clear ( index, channel, clearMask );
180
}
181

    
182

    
183
/******************************************************************************
184
  Function:
185
    void SYS_PORTS_DirectionSelect( PORTS_MODULE_ID index,
186
                                                                SYS_PORTS_PIN_DIRECTION pinDir,
187
                                                                PORTS_CHANNEL channel,
188
                                                                PORTS_DATA_MASK mask )
189
  Summary:
190
    Enables the direction for the selected port.
191

192
  Description:
193
    This function enables the direction for the selected port.
194

195
  Remarks:
196
    None.
197
*/
198

    
199
void SYS_PORTS_DirectionSelect( PORTS_MODULE_ID index,
200
                             SYS_PORTS_PIN_DIRECTION pinDir,
201
                             PORTS_CHANNEL channel,
202
                             PORTS_DATA_MASK mask )
203
{
204
    if (pinDir == SYS_PORTS_DIRECTION_INPUT)
205
    {
206
        PLIB_PORTS_DirectionInputSet(index, channel, mask);
207
    }
208
    else
209
    {
210
        PLIB_PORTS_DirectionOutputSet(index, channel, mask);
211
    }
212
}
213

    
214

    
215
/******************************************************************************
216
  Function:
217
    PORTS_DATA_MASK SYS_PORTS_DirectionGet( PORTS_MODULE_ID index,
218
                                            PORTS_CHANNEL channel )
219

220
  Summary:
221
    Reads the port direction for the selected port.
222

223
  Description:
224
    This function reads the port direction for the selected port.
225

226
  Remarks:
227
    None.
228
*/
229

    
230
PORTS_DATA_MASK SYS_PORTS_DirectionGet( PORTS_MODULE_ID index, PORTS_CHANNEL channel )
231
{
232
    return PLIB_PORTS_DirectionGet( index, channel );
233
}
234

    
235

    
236
/******************************************************************************
237
  Function:
238
    void SYS_PORTS_Toggle( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
239
                           PORTS_DATA_MASK toggleMask )
240

241
  Summary:
242
    Toggles the selected digital port pins.
243

244
  Description:
245
    This function toggles the selected digital port pins.
246

247
  Remarks:
248
    None.
249
*/
250

    
251
void SYS_PORTS_Toggle( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
252
                       PORTS_DATA_MASK toggleMask )
253
{
254
    PLIB_PORTS_Toggle( index, channel, toggleMask );
255
}
256

    
257

    
258
/******************************************************************************
259
  Function:
260
    void SYS_PORTS_OpenDrainEnable( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
261
                                     PORTS_DATA_MASK mask )
262

263
  Summary:
264
    Enables the open drain functionality for the selected port.
265

266
  Description:
267
    This function enables the open drain functionality for the selected port.
268

269
  Remarks:
270
    None.
271
*/
272

    
273
void SYS_PORTS_OpenDrainEnable( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
274
                                PORTS_DATA_MASK mask )
275
{
276
#if defined(PLIB_PORTS_ExistsPortsOpenDrain)
277
    if(PLIB_PORTS_ExistsPortsOpenDrain(index))
278
    {
279
        PLIB_PORTS_OpenDrainEnable( index, channel, mask );
280
    }
281
#endif
282
}
283

    
284

    
285
/******************************************************************************
286
  Function:
287
    void SYS_PORTS_OpenDrainDisable( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
288
                                     PORTS_DATA_MASK mask )
289

290
  Summary:
291
    Disables the open drain functionality for the selected port.
292

293
  Description:
294
    This function disables the open drain functionality for the selected port.
295

296
  Remarks:
297
    None.
298
*/
299

    
300
void SYS_PORTS_OpenDrainDisable( PORTS_MODULE_ID index, PORTS_CHANNEL channel,
301
                                 PORTS_DATA_MASK mask )
302
{
303
#if defined(PLIB_PORTS_ExistsPortsOpenDrain)
304
    if(PLIB_PORTS_ExistsPortsOpenDrain(index))
305
    {
306
        PLIB_PORTS_OpenDrainDisable( index, channel, mask );
307
    }
308
#endif
309
}
310

    
311

    
312
// *****************************************************************************
313
// *****************************************************************************
314
// Section: SYS Change Notification Pins Routines
315
// *****************************************************************************
316
// *****************************************************************************
317

    
318
/******************************************************************************
319
  Function:
320
    void SYS_PORTS_ChangeNotificationGlobalEnable( PORTS_MODULE_ID index )
321

322
  Summary:
323
    Globally enables the change notification.
324

325
  Description:
326
    This function globally enables the change notification.
327

328
  Remarks:
329
    None.
330
*/
331

    
332
void SYS_PORTS_ChangeNotificationGlobalEnable( PORTS_MODULE_ID index )
333
{
334
#if defined(PLIB_PORTS_ExistsChangeNotice)
335
    if(PLIB_PORTS_ExistsChangeNotice(index))
336
    {
337
        PLIB_PORTS_ChangeNoticeEnable( index );
338
    }
339
#endif
340
}
341

    
342
/******************************************************************************
343
  Function:
344
    void SYS_PORTS_ChangeNotificationGlobalDisable( PORTS_MODULE_ID index )
345

346
  Summary:
347
    Globally disables the change notification.
348

349
  Description:
350
    This function globally disables the change notification.
351

352
  Remarks:
353
    None.
354
*/
355

    
356
void SYS_PORTS_ChangeNotificationGlobalDisable( PORTS_MODULE_ID index )
357
{
358
#if defined(PLIB_PORTS_ExistsChangeNotice)
359
    if(PLIB_PORTS_ExistsChangeNotice(index))
360
    {
361
        PLIB_PORTS_ChangeNoticeDisable( index );
362
    }
363
#endif
364
}
365

    
366
/******************************************************************************
367
  Function:
368
    void SYS_PORTS_GlobalChangeNotificationDisable( PORTS_MODULE_ID index )
369

370
  Summary:
371
    Globally disables the change notification for the selected port.
372

373
  Description:
374
    This function globally disables the change notification for the selected port.
375

376
  Remarks:
377
    None.
378
*/
379

    
380
void SYS_PORTS_GlobalChangeNotificationDisable( PORTS_MODULE_ID index )
381
{
382
#if defined(PLIB_PORTS_ExistsChangeNotice)
383
    if(PLIB_PORTS_ExistsChangeNotice(index))
384
    {
385
        PLIB_PORTS_ChangeNoticeDisable( index );
386
    }
387
#endif
388
}
389

    
390

    
391
/******************************************************************************
392
  Function:
393
    void SYS_PORTS_ChangeNotificationEnable( PORTS_MODULE_ID index,
394
                                             PORTS_CHANGE_NOTICE_PIN pinNum,
395
                                             SYS_PORTS_PULLUP_PULLDOWN_STATUS value )
396

397
  Summary:
398
    Enables the change notification for the selected port.
399

400
  Description:
401
    This function enables the change notification for the selected port.
402

403
  Remarks:
404
    None.
405
*/
406

    
407
void SYS_PORTS_ChangeNotificationEnable( PORTS_MODULE_ID index,
408
                                         PORTS_CHANGE_NOTICE_PIN pinNum,
409
                                         SYS_PORTS_PULLUP_PULLDOWN_STATUS value )
410
{
411
#if defined(PLIB_PORTS_ExistsChangeNoticePullUp)
412
    if(PLIB_PORTS_ExistsChangeNoticePullUp(index))
413
    {
414
        switch(value)
415
        {
416
            case SYS_PORTS_PULLUP_DISABLE:
417
                PLIB_PORTS_ChangeNoticePullUpDisable(index, pinNum);
418
                break;
419
            case SYS_PORTS_PULLUP_ENABLE:
420
                PLIB_PORTS_ChangeNoticePullUpEnable(index, pinNum);
421
                break;
422
        }
423
    }
424
#endif
425

    
426
#if defined(PLIB_PORTS_ExistsPinChangeNotice)
427
    if(PLIB_PORTS_ExistsPinChangeNotice(index))
428
    {
429
        PLIB_PORTS_PinChangeNoticeEnable( index, pinNum );
430
    }
431
#endif
432
}
433

    
434

    
435
/******************************************************************************
436
  Function:
437
    void SYS_PORTS_ChangeNotificationDisable( PORTS_MODULE_ID index,
438
                                              PORTS_CHANGE_NOTICE_PIN pinNum )
439

440
  Summary:
441
    Disables the change notification for the selected port.
442

443
  Description:
444
    This function disables the change notification for the selected port.
445

446
  Remarks:
447
    None.
448
*/
449

    
450
void SYS_PORTS_ChangeNotificationDisable( PORTS_MODULE_ID index,
451
                                          PORTS_CHANGE_NOTICE_PIN pinNum )
452
{
453
#if defined(PLIB_PORTS_ExistsPinChangeNotice)
454
    if(PLIB_PORTS_ExistsPinChangeNotice(index))
455
    {
456
        PLIB_PORTS_PinChangeNoticeDisable( index, pinNum );
457
    }
458
#endif
459
}
460

    
461

    
462
/******************************************************************************
463
  Function:
464
    void SYS_PORTS_ChangeNotificationInIdleModeEnable( PORTS_MODULE_ID index )
465

466
  Summary:
467
    Enables the change notification for the selected port in Sleep or Idle mode.
468

469
  Description:
470
    This function enables the change notification for the selected port in Sleep
471
    or Idle mode.
472

473
  Remarks:
474
    None.
475
*/
476

    
477
void SYS_PORTS_ChangeNotificationInIdleModeEnable( PORTS_MODULE_ID index )
478
{
479
#if defined(PLIB_PORTS_ExistsChangeNoticeInIdle)
480
    if(PLIB_PORTS_ExistsChangeNoticeInIdle(index))
481
    {
482
        PLIB_PORTS_ChangeNoticeInIdleEnable( index );
483
    }
484
#endif
485
}
486

    
487

    
488
// *****************************************************************************
489
/* Function:
490
    void SYS_PORTS_ChangeNotificationInIdleModeDisable( PORTS_MODULE_ID index)
491

492
  Summary:
493
    Disables the change notification for the selected port in Sleep or Idle mode.
494

495
  Description:
496
    This function disables the change notification for the selected port in Sleep
497
    or Idle mode.
498

499
  Remarks:
500
    None.
501
*/
502

    
503
void SYS_PORTS_ChangeNotificationInIdleModeDisable( PORTS_MODULE_ID index )
504
{
505
#if defined(PLIB_PORTS_ExistsChangeNoticeInIdle)
506
    if(PLIB_PORTS_ExistsChangeNoticeInIdle(index))
507
    {
508
        PLIB_PORTS_ChangeNoticeInIdleDisable( index );
509
    }
510
#endif
511
}
512

    
513

    
514
// *****************************************************************************
515
/* Function:
516
    void SYS_PORTS_ChangeNotificationPullUpEnable ( PORTS_MODULE_ID         index,
517
                                                    PORTS_CHANGE_NOTICE_PIN pinNum )
518

519
  Summary:
520
    Enables weak pull-up on change notification pin.
521

522
  Description:
523
    This function enables weak pull-up on change notification pin.
524

525
  Remarks:
526
    None.
527
*/
528

    
529
void SYS_PORTS_ChangeNotificationPullUpEnable ( PORTS_MODULE_ID         index,
530
                                                PORTS_CHANGE_NOTICE_PIN pinNum )
531
{
532
#if defined(PLIB_PORTS_ExistsChangeNoticePullUp)
533
    if(PLIB_PORTS_ExistsChangeNoticePullUp(index))
534
    {
535
        PLIB_PORTS_ChangeNoticePullUpEnable ( index, pinNum );
536
    }
537
#endif
538
}
539

    
540

    
541
// *****************************************************************************
542
/* Function:
543
    void SYS_PORTS_ChangeNotificationPullUpDisable ( PORTS_MODULE_ID         index,
544
                                                    PORTS_CHANGE_NOTICE_PIN pinNum )
545

546
  Summary:
547
    Disables pull-up on input change.
548

549
  Description:
550
    This function disables pull-up on input change.
551

552
  Remarks:
553
    None.
554
*/
555

    
556
void SYS_PORTS_ChangeNotificationPullUpDisable ( PORTS_MODULE_ID         index,
557
                                                PORTS_CHANGE_NOTICE_PIN pinNum )
558
{
559
#if defined(PLIB_PORTS_ExistsChangeNoticePullUp)
560
    if(PLIB_PORTS_ExistsChangeNoticePullUp(index))
561
    {
562
        PLIB_PORTS_ChangeNoticePullUpDisable ( index, pinNum );
563
    }
564
#endif
565
}
566

    
567

    
568
// *****************************************************************************
569
// *****************************************************************************
570
// Section: SYS PORT PINS Control Routines
571
// *****************************************************************************
572
// *****************************************************************************
573

    
574
// *****************************************************************************
575
/* Function:
576
    void SYS_PORTS_PinModeSelect ( PORTS_MODULE_ID index, PORTS_ANALOG_PIN pin,
577
                                                                    PORTS_PIN_MODE mode)
578

579
  Summary:
580
    Enables the selected pin as analog or digital.
581

582
  Description:
583
    This function enables the selected pin as analog or digital.
584

585
 Remarks:
586
    None.
587
*/
588

    
589
void SYS_PORTS_PinModeSelect ( PORTS_MODULE_ID index, PORTS_ANALOG_PIN pin,
590
                                                                PORTS_PIN_MODE mode)
591
{
592
#if defined(PLIB_PORTS_ExistsPinMode)
593
    if(PLIB_PORTS_ExistsPinMode(index))
594
    {
595
        PLIB_PORTS_PinModeSelect ( index, pin, mode);
596
    }
597
#endif
598
}
599

    
600

    
601
// *****************************************************************************
602
/* Function:
603
    void SYS_PORTS_PinWrite ( PORTS_MODULE_ID index,
604
                              PORTS_CHANNEL channel,
605
                              PORTS_BIT_POS bitPos
606
                              bool value )
607
  Summary:
608
    Writes the selected digital pin.
609

610
  Description:
611
    This function writes the selected digital pin.
612

613
  Remarks:
614
    None.
615
*/
616

    
617
void SYS_PORTS_PinWrite ( PORTS_MODULE_ID index,
618
                          PORTS_CHANNEL channel,
619
                          PORTS_BIT_POS bitPos,
620
                          bool value )
621
{
622
    PLIB_PORTS_PinWrite ( index, channel, bitPos, value );
623
}
624

    
625

    
626
// *****************************************************************************
627
/* Function:
628
    bool SYS_PORTS_PinRead ( PORTS_MODULE_ID index,
629
                             PORTS_CHANNEL channel,
630
                             PORTS_BIT_POS bitPos )
631

632
  Summary:
633
    Reads the selected digital pin.
634

635
  Description:
636
    This function reads the selected digital pin.
637

638
  Remarks:
639
    None.
640
*/
641

    
642
bool SYS_PORTS_PinRead ( PORTS_MODULE_ID index,
643
                         PORTS_CHANNEL channel,
644
                         PORTS_BIT_POS bitPos )
645
{
646
    return PLIB_PORTS_PinGet ( index, channel, bitPos );
647
}
648

    
649

    
650
// *****************************************************************************
651
/* Function:
652
    void SYS_PORTS_PinToggle ( PORTS_MODULE_ID index,
653
                               PORTS_CHANNEL channel,
654
                               PORTS_BIT_POS bitPos )
655

656
  Summary:
657
    Toggles the selected digital pin.
658

659
  Description:
660
    This function toggles the selected digital pin.
661

662
  Remarks:
663
    None.
664
*/
665

    
666
void SYS_PORTS_PinToggle ( PORTS_MODULE_ID index,
667
                           PORTS_CHANNEL channel,
668
                           PORTS_BIT_POS bitPos )
669
{
670
    PLIB_PORTS_PinToggle ( index, channel, bitPos );
671
}
672

    
673

    
674
// *****************************************************************************
675
/* Function:
676
    void SYS_PORTS_PinSet( PORTS_MODULE_ID index,
677
                           PORTS_CHANNEL channel,
678
                           PORTS_BIT_POS bitPos )
679

680
  Summary:
681
    Sets the selected digital pin/latch.
682

683
  Description:
684
    This function sets the selected digital pin/latch.
685

686
  Remarks:
687
    None.
688
*/
689

    
690
void SYS_PORTS_PinSet( PORTS_MODULE_ID index,
691
                       PORTS_CHANNEL channel,
692
                       PORTS_BIT_POS bitPos )
693
{
694
    PLIB_PORTS_PinSet( index, channel, bitPos );
695
}
696

    
697

    
698
// *****************************************************************************
699
/* Function:
700
    void SYS_PORTS_PinClear ( PORTS_MODULE_ID index,
701
                              PORTS_CHANNEL channel,
702
                              PORTS_BIT_POS bitPos )
703

704
  Summary:
705
    Clears the selected digital pin.
706

707
  Description:
708
    This function clears the selected digital pin.
709

710
  Remarks:
711
    None.
712
*/
713

    
714
void SYS_PORTS_PinClear ( PORTS_MODULE_ID index,
715
                          PORTS_CHANNEL channel,
716
                          PORTS_BIT_POS bitPos )
717
{
718
    PLIB_PORTS_PinClear ( index, channel, bitPos );
719
}
720

    
721

    
722
// *****************************************************************************
723
/* Function:
724
    void SYS_PORTS_PinDirectionSelect ( PORTS_MODULE_ID index,
725
                                     SYS_PORTS_PIN_DIRECTION pinDir,
726
                                     PORTS_CHANNEL channel,
727
                                     PORTS_BIT_POS bitPos )
728
  Summary:
729
    Enables the direction for the selected pin.
730

731
  Description:
732
    This function enables the direction for the selected pin.
733

734
  Remarks:
735
    None.
736
*/
737

    
738
void SYS_PORTS_PinDirectionSelect ( PORTS_MODULE_ID index,
739
                                 SYS_PORTS_PIN_DIRECTION pinDir,
740
                                 PORTS_CHANNEL channel,
741
                                 PORTS_BIT_POS bitPos )
742
{
743
    if (pinDir == SYS_PORTS_DIRECTION_OUTPUT)
744
    {
745
        PLIB_PORTS_PinDirectionOutputSet(index, channel, bitPos);
746
    }
747
    else
748
    {
749
        PLIB_PORTS_PinDirectionInputSet(index, channel, bitPos);
750
    }
751
}
752

    
753

    
754
// *****************************************************************************
755
/* Function:
756
    void SYS_PORTS_PinOpenDrainEnable ( PORTS_MODULE_ID index,
757
                                        PORTS_CHANNEL channel,
758
                                        PORTS_BIT_POS bitPos )
759

760
  Summary:
761
    Enables the open-drain functionality for the selected pin.
762

763
  Description:
764
    This function enables the open-drain functionality for the selected pin.
765

766
  Remarks:
767
    None.
768
*/
769

    
770
void SYS_PORTS_PinOpenDrainEnable ( PORTS_MODULE_ID index,
771
                                    PORTS_CHANNEL channel,
772
                                    PORTS_BIT_POS bitPos )
773
{
774
#if defined(PLIB_PORTS_ExistsPortsOpenDrain)
775
    if(PLIB_PORTS_ExistsPortsOpenDrain(index))
776
    {
777
        PLIB_PORTS_PinOpenDrainEnable ( index, channel, bitPos );
778
    }
779
#endif
780
}
781

    
782

    
783
// *****************************************************************************
784
/* Function:
785
    void SYS_PORTS_PinOpenDrainDisable ( PORTS_MODULE_ID index,
786
                                         PORTS_CHANNEL channel,
787
                                         PORTS_BIT_POS bitPos )
788

789
  Summary:
790
    Disables the open-drain functionality for the selected pin.
791

792
  Description:
793
    This function disables the open-drain functionality for the selected pin.
794

795
  Remarks:
796
    None.
797
*/
798

    
799
void SYS_PORTS_PinOpenDrainDisable ( PORTS_MODULE_ID index,
800
                                     PORTS_CHANNEL channel,
801
                                     PORTS_BIT_POS bitPos )
802
{
803
#if defined(PLIB_PORTS_ExistsPortsOpenDrain)
804
    if(PLIB_PORTS_ExistsPortsOpenDrain(index))
805
    {
806
        PLIB_PORTS_PinOpenDrainDisable ( index, channel, bitPos );
807
    }
808
#endif
809
}
810

    
811

    
812
// *****************************************************************************
813
/* Function:
814
    void SYS_PORTS_RemapInput( PORTS_MODULE_ID      index,
815
                                                          PORTS_REMAP_INPUT_FUNCTION function,
816
                                                          PORTS_REMAP_INPUT_PIN      remapPin )
817

818
  Summary:
819
    Input/Output (I/O) function remapping.
820

821
  Description:
822
    This function controls the I/O function remapping.
823

824
  Precondition:
825
    None.
826
*/        
827
void SYS_PORTS_RemapInput( PORTS_MODULE_ID      index,
828
                                                   PORTS_REMAP_INPUT_FUNCTION function,
829
                                                   PORTS_REMAP_INPUT_PIN      remapPin )
830
{
831
#if defined(PLIB_PORTS_ExistsRemapInput)
832
    if(PLIB_PORTS_ExistsRemapInput(index))
833
    {
834
        PLIB_DEVCON_SystemUnlock(DEVCON_ID_0);
835
        PLIB_DEVCON_DeviceRegistersUnlock(DEVCON_ID_0, DEVCON_PPS_REGISTERS);
836
        PLIB_PORTS_RemapInput( index, function, remapPin);
837
    }
838
#endif
839
}
840

    
841
// *****************************************************************************
842
/* Function:
843
    void SYS_PORTS_RemapOutput( PORTS_MODULE_ID      index,
844
                                      PORTS_REMAP_OUTPUT_FUNCTION function,
845
                                      PORTS_REMAP_OUTPUT_PIN      remapPin )
846

847
  Summary:
848
    Input/Output (I/O) function remapping.
849

850
  Description:
851
    This function controls the I/O function remapping.
852

853
  Precondition:
854
    None.
855
*/
856
void SYS_PORTS_RemapOutput( PORTS_MODULE_ID      index,
857
                                                    PORTS_REMAP_OUTPUT_FUNCTION function,
858
                                                    PORTS_REMAP_OUTPUT_PIN      remapPin )
859
{
860
#if defined(PLIB_PORTS_ExistsRemapOutput)
861
    if(PLIB_PORTS_ExistsRemapOutput(index))
862
    {
863
        PLIB_DEVCON_SystemUnlock(DEVCON_ID_0);
864
        PLIB_DEVCON_DeviceRegistersUnlock(DEVCON_ID_0, DEVCON_PPS_REGISTERS);
865
        PLIB_PORTS_RemapOutput( index, function, remapPin);
866
    }
867
#endif
868
}
869

    
870
/*******************************************************************************
871
 End of File
872
*/