Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / driver / rtcc / src / drv_rtcc_static.c @ eaef5bd1

History | View | Annotate | Download (4.25 KB)

1
/*******************************************************************************
2
  RTCC Driver Initialization File
3

4
  File Name:
5
    drv_rtcc_static.c
6

7
  Summary:
8
    This file contains source code necessary to initialize the RTCC driver.
9

10
  Description:
11
   RTCC Driver includes initialization and other routines with small footprtint.
12
 *******************************************************************************/
13

    
14
// DOM-IGNORE-BEGIN
15
/*******************************************************************************
16
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.
17

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

23
You should refer to the license agreement accompanying this Software for
24
additional information regarding your rights and obligations.
25

26
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
27
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
28
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
29
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
30
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
31
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
32
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
33
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
34
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
35
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
36
 *******************************************************************************/
37
// DOM-IGNORE-END
38

    
39
// *****************************************************************************
40
// *****************************************************************************
41
// Header Includes
42
// *****************************************************************************
43
// *****************************************************************************
44
#include "peripheral/rtcc/plib_rtcc.h"
45
#include "peripheral/devcon/plib_devcon.h"
46

    
47
// *****************************************************************************
48
// *****************************************************************************
49
// Section: RTCC static driver functions
50
// *****************************************************************************
51
// *****************************************************************************
52
void DRV_RTCC_Initialize(void) {
53
  PLIB_DEVCON_SystemUnlock(DEVCON_ID_0); /* Unlock System */
54

    
55
  /* Initialize RTCC */
56
  PLIB_RTCC_WriteEnable(RTCC_ID_0); /* Enable writes to RTCC */
57
  PLIB_RTCC_Disable(RTCC_ID_0);     /* Disable clock to RTCC */
58
  while (PLIB_RTCC_ClockRunningStatus(RTCC_ID_0))
59
    ;                                          /*Check if clock is disabled */
60
  PLIB_RTCC_RTCTimeSet(RTCC_ID_0, 0x23595900); /* Set RTCC time */
61
  PLIB_RTCC_RTCDateSet(RTCC_ID_0, 0x14010100); /* Set RTCC date */
62
  PLIB_RTCC_AlarmDisable(RTCC_ID_0);           /* Disable alarm */
63
  while (PLIB_RTCC_AlarmSyncStatusGet(RTCC_ID_0))
64
    ;                                            /* Wait for disable */
65
  PLIB_RTCC_AlarmTimeSet(RTCC_ID_0, 0x00000500); /* Set RTCC alarm time */
66
  PLIB_RTCC_AlarmDateSet(RTCC_ID_0, 0x00010100); /* Set RTCC alarm date */
67
  PLIB_RTCC_AlarmMaskModeSelect(
68
      RTCC_ID_0, RTCC_ALARM_EVERY_SECOND); /* Set RTCC alarm mode */
69
}
70

    
71
void DRV_RTCC_Start(void) {
72
  PLIB_RTCC_Enable(RTCC_ID_0);
73
}
74

    
75
void DRV_RTCC_Stop(void) {
76
  PLIB_RTCC_Disable(RTCC_ID_0);
77
}
78

    
79
void DRV_RTCC_ClockOutput(void) {
80
  PLIB_RTCC_ClockOutputEnable(RTCC_ID_0);
81
}
82

    
83
uint32_t DRV_RTCC_TimeGet(void) {
84
  return PLIB_RTCC_RTCTimeGet(RTCC_ID_0);
85
}
86

    
87
uint32_t DRV_RTCC_DateGet(void) {
88
  return PLIB_RTCC_RTCDateGet(RTCC_ID_0);
89
}
90

    
91
uint32_t DRV_RTCC_AlarmTimeGet(void) {
92
  return PLIB_RTCC_AlarmTimeGet(RTCC_ID_0);
93
}
94

    
95
uint32_t DRV_RTCC_AlarmDateGet(void) {
96
  return PLIB_RTCC_AlarmDateGet(RTCC_ID_0);
97
}
98

    
99
/*******************************************************************************
100
 End of File
101
*/