5
Last change
on this file since 68565b0 was
68565b0,
checked in by Pavel Pisa <pisa@…>, on 06/28/16 at 14:15:38
|
arm/raspberrypi: run VideoCore? and mailbox code through rtems.uncrustify.
Some changes have been reverted to keep readability.
For example squash of BCM2835_MBOX_TAG_* defines
which are visually aligned in column.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup raspberrypi |
---|
5 | * |
---|
6 | * @brief mailbox support. |
---|
7 | */ |
---|
8 | /* |
---|
9 | * Copyright (c) 2015 Yang Qiao |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * |
---|
14 | * http://www.rtems.org/license/LICENSE |
---|
15 | * |
---|
16 | */ |
---|
17 | |
---|
18 | #include <stdint.h> |
---|
19 | #include <stdbool.h> |
---|
20 | #include <bsp.h> |
---|
21 | #include <bsp/raspberrypi.h> |
---|
22 | #include <bsp/mailbox.h> |
---|
23 | |
---|
24 | #define BCM2835_MBOX_DATA_MASK( data ) ( data & 0xFFFFFFF0U ) |
---|
25 | #define BCM2835_MBOX_CHANNEL_MASK( data ) ( data & 0xFU ) |
---|
26 | |
---|
27 | static inline bool bcm2835_mailbox_is_empty( void ) |
---|
28 | { |
---|
29 | return ( BCM2835_REG( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_EMPTY ); |
---|
30 | } |
---|
31 | |
---|
32 | static inline bool bcm2835_mailbox_is_full( void ) |
---|
33 | { |
---|
34 | return ( BCM2835_REG( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_FULL ); |
---|
35 | } |
---|
36 | |
---|
37 | unsigned int raspberrypi_mailbox_read( unsigned int channel ) |
---|
38 | { |
---|
39 | unsigned int raw; |
---|
40 | unsigned int read_channel; |
---|
41 | |
---|
42 | while ( 1 ) { |
---|
43 | while ( bcm2835_mailbox_is_empty() ) ; |
---|
44 | |
---|
45 | raw = BCM2835_REG( BCM2835_MBOX_READ ); |
---|
46 | read_channel = BCM2835_MBOX_CHANNEL_MASK( raw ); |
---|
47 | |
---|
48 | if ( read_channel == channel ) |
---|
49 | return BCM2835_MBOX_DATA_MASK( raw ); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | void raspberrypi_mailbox_write( |
---|
54 | unsigned int channel, |
---|
55 | unsigned int data |
---|
56 | ) |
---|
57 | { |
---|
58 | while ( bcm2835_mailbox_is_full() ) ; |
---|
59 | |
---|
60 | BCM2835_REG( BCM2835_MBOX_WRITE ) = |
---|
61 | BCM2835_MBOX_DATA_MASK( data ) | |
---|
62 | BCM2835_MBOX_CHANNEL_MASK( channel ); |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.