Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / driver / usart / src / drv_usart_static_byte_model.c @ eaef5bd1

History | View | Annotate | Download (4.46 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  USART driver static implementation of Byte model.
4

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    drv_usart_static_byte_model.c
10

11
  Summary:
12
    Source code for the USART driver static implementation of Byte model.
13

14
  Description:
15
    This file contains the source code for the static implementation of the
16
    USART driver Byte model.
17

18
  Remarks:
19
    Static interfaces incorporate the driver instance number within the names
20
    of the routines, eliminating the need for an object ID or object handle.
21

22
    Static single-open interfaces also eliminate the need for the open handle.
23
*******************************************************************************/
24

    
25
//DOM-IGNORE-BEGIN
26
/*******************************************************************************
27
Copyright (c) 2015 released Microchip Technology Inc.  All rights reserved.
28

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

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

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

    
57
// *****************************************************************************
58
// *****************************************************************************
59
// Section: Global Data
60
// *****************************************************************************
61
// *****************************************************************************
62
extern DRV_USART_OBJ  gDrvUSART0Obj ;
63

    
64
// *****************************************************************************
65
// *****************************************************************************
66
// Section: Instance 0 static driver functions
67
// *****************************************************************************
68
// *****************************************************************************
69

    
70
uint8_t DRV_USART0_ReadByte(void)
71
{
72
    uint8_t readValue;
73
        
74
    /* Receive one byte */
75
    readValue = PLIB_USART_ReceiverByteReceive(USART_ID_2);
76

    
77
    return readValue;
78
}
79

    
80
void DRV_USART0_WriteByte(const uint8_t byte)
81
{
82
    /* Wait till TX buffer is available as blocking operation is selected */
83
    while(PLIB_USART_TransmitterBufferIsFull(USART_ID_2));
84
    /* Send one byte */
85
    PLIB_USART_TransmitterByteSend(USART_ID_2, byte);
86
    SYS_INT_SourceEnable(INT_SOURCE_USART_2_TRANSMIT);
87
}
88

    
89
unsigned int DRV_USART0_ReceiverBufferSizeGet(void)
90
{
91
    return 8;
92
}
93

    
94
unsigned int DRV_USART0_TransmitBufferSizeGet(void)
95
{
96
    return 8;
97
}
98

    
99
bool DRV_USART0_ReceiverBufferIsEmpty( void )
100
{
101
    /* Check the status of receiver buffer */
102
    return(!PLIB_USART_ReceiverDataIsAvailable(USART_ID_2));
103
}
104

    
105
bool DRV_USART0_TransmitBufferIsFull(void)
106
{
107
    /* Check the status of transmitter buffer */
108
    return(PLIB_USART_TransmitterBufferIsFull(USART_ID_2));
109
}
110

    
111
/*******************************************************************************
112
 End of File
113
*/