Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / http_server / firmware / src / system_config / pic32mx_eth_sk2_encx24j600 / framework / system / ports / src / sys_ports_static.c @ eaef5bd1

History | View | Annotate | Download (25.3 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

    
81
    /* PORT A Initialization */
82
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_ODC);
83
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_A,  SYS_PORT_A_LAT);
84
        PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_A,  SYS_PORT_A_TRIS ^ 0xFFFF);
85

    
86
    /* PORT B Initialization */
87
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_ODC);
88
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_B,  SYS_PORT_B_LAT);
89
        PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_B,  SYS_PORT_B_TRIS ^ 0xFFFF);
90

    
91
}
92

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

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

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

103
  Remarks:
104
    None.
105
*/
106

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

    
112

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

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

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

124
  Remarks:
125
    None.
126
*/
127

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

    
135

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

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

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

148
  Remarks:
149
    None.
150
*/
151

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

    
159

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

165
  Summary:
166
    Clears the selected digital port.
167

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

171
  Remarks:
172
    None.
173
*/
174

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

    
181

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

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

194
  Remarks:
195
    None.
196
*/
197

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

    
213

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

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

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

225
  Remarks:
226
    None.
227
*/
228

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

    
234

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

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

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

246
  Remarks:
247
    None.
248
*/
249

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

    
256

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

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

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

268
  Remarks:
269
    None.
270
*/
271

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

    
283

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

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

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

295
  Remarks:
296
    None.
297
*/
298

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

    
310

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

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

321
  Summary:
322
    Globally enables the change notification.
323

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

327
  Remarks:
328
    None.
329
*/
330

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

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

345
  Summary:
346
    Globally disables the change notification.
347

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

351
  Remarks:
352
    None.
353
*/
354

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

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

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

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

375
  Remarks:
376
    None.
377
*/
378

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

    
389

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

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

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

402
  Remarks:
403
    None.
404
*/
405

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

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

    
433

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

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

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

445
  Remarks:
446
    None.
447
*/
448

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

    
460

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

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

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

472
  Remarks:
473
    None.
474
*/
475

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

    
486

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

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

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

498
  Remarks:
499
    None.
500
*/
501

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

    
512

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

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

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

524
  Remarks:
525
    None.
526
*/
527

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

    
539

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

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

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

551
  Remarks:
552
    None.
553
*/
554

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

    
566

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

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

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

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

584
 Remarks:
585
    None.
586
*/
587

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

    
599

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

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

612
  Remarks:
613
    None.
614
*/
615

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

    
624

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

631
  Summary:
632
    Reads the selected digital pin.
633

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

637
  Remarks:
638
    None.
639
*/
640

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

    
648

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

655
  Summary:
656
    Toggles the selected digital pin.
657

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

661
  Remarks:
662
    None.
663
*/
664

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

    
672

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

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

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

685
  Remarks:
686
    None.
687
*/
688

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

    
696

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

703
  Summary:
704
    Clears the selected digital pin.
705

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

709
  Remarks:
710
    None.
711
*/
712

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

    
720

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

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

733
  Remarks:
734
    None.
735
*/
736

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

    
752

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

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

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

765
  Remarks:
766
    None.
767
*/
768

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

    
781

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

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

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

794
  Remarks:
795
    None.
796
*/
797

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

    
810

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

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

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

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

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

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

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

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

    
869
/*******************************************************************************
870
 End of File
871
*/