Skip to content

Commit

Permalink
[dox] replace backticks by tilde for code block in markdown file
Browse files Browse the repository at this point in the history
so it works in both doxygen and github
  • Loading branch information
flixr committed Feb 27, 2014
1 parent 6538222 commit 902768a
Showing 1 changed file with 98 additions and 98 deletions.
196 changes: 98 additions & 98 deletions sw/airborne/subsystems/datalink/README.md
Expand Up @@ -5,15 +5,15 @@ HOWTO export
------------

- Export library: in this folder, type
```
~~~
make export_lib
```
~~~
be sure that you have correctly build the paparazzi project (`make` in the main directory)

- The default export directory is `${PAPARAZZI_HOME}/var/export`, to change it:
```
~~~
EXPORT_ROOT=<your_export_root_dir> make export_lib
```
~~~

- `make clean` will only remove the export directory

Expand Down Expand Up @@ -41,139 +41,139 @@ HOWTO use the datalink library

4. Message parsing and includes:
in a C file of you project (for example a file named `datalink.c`), add the following lines:
```
#define DATALINK_C 1 // this should be placed before the includes
~~~{.c}
#define DATALINK_C 1 // this should be placed before the includes
#inlcude "uart.h" // or change this include to the header of your actual device interface
#include "downlink.h"
#inlcude "uart.h" // or change this include to the header of your actual device interface
#include "downlink.h"
void dl_parse_msg(void) {
<add your code to parse messages here>
}
```
void dl_parse_msg(void) {
<add your code to parse messages here>
}
~~~
You also need to poll for new characters, which means that you have to call the `DatalinkEvent()` function in your main loop.
This function is non-blocking and calls the decoder on each received byte. Finally the `dl_parse_msg` function is called when a complete message is received (checksum is valid).

Example project for Mbeb dev board
==================================

Test file `test_dl.cpp` (assuming you already have the Mbed library)
```
#include "mbed.h"
~~~{.c}
#include "mbed.h"
Ticker daq;
Serial uart1(p9, p10);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Ticker daq;
Serial uart1(p9, p10);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
/**** PPRZ interface ****/
#define DATALINK_C 1
#define UartCheckFreeSpace(_len) uart1.writeable()
#define UartTransmit(_c) uart1.putc(_c)
#define UartSendMessage() {}
#define UartChAvailable() uart1.readable()
#define UartGetch() uart1.getc()
/**** PPRZ interface ****/
#define DATALINK_C 1
#define UartCheckFreeSpace(_len) uart1.writeable()
#define UartTransmit(_c) uart1.putc(_c)
#define UartSendMessage() {}
#define UartChAvailable() uart1.readable()
#define UartGetch() uart1.getc()
#include "downlink.h"
#include "downlink.h"
void dl_parse_msg(void) {
int msg_id = dl_buffer[1];
void dl_parse_msg(void) {
int msg_id = dl_buffer[1];
switch (msg_id) {
case DL_PONG:
led2 =! led2; // toggle led on new PONG message
break;
default:
break;
}
switch (msg_id) {
case DL_PONG:
led2 =! led2; // toggle led on new PONG message
break;
default:
break;
}
}
/************************/
}
/************************/
void cb()
{
// Toggle led 1 when sending PING
led1 =! led1;
// Send PPRZ message
DOWNLINK_SEND_PING(DefaultChannel, DefaultDevice);
}
void cb()
{
// Toggle led 1 when sending PING
led1 =! led1;
// Send PPRZ message
DOWNLINK_SEND_PING(DefaultChannel, DefaultDevice);
}
int main()
{
uart1.baud(57600); // set serial baud rate for PPRZ
led1 = led2 = 0; // turn off all LEDs
int main()
{
uart1.baud(57600); // set serial baud rate for PPRZ
led1 = led2 = 0; // turn off all LEDs
daq.attach(&cb, 1); // callback
daq.attach(&cb, 1); // callback
while(1) {
while(1) {
// Your (non-blocking) code
// Your (non-blocking) code
// Poll new bytes on uart
DatalinkEvent();
// Poll new bytes on uart
DatalinkEvent();
} // ~while
} // ~main
```
} // ~while
} // ~main
~~~

With the makefile:
```
# This file was automagically generated by mbed.org with PPRZ datalink library addition
~~
# This file was automagically generated by mbed.org with PPRZ datalink library addition

GCC_BIN = /usr/bin/
PROJECT = Test_PPRZ_Datalink
OBJECTS = ./test_dl.o
SYS_OBJECTS = ./mbed/LPC1768/GCC_CS/sys.o ./mbed/LPC1768/GCC_CS/cmsis_nvic.o ./mbed/LPC1768/GCC_CS/system_LPC17xx.o ./mbed/LPC1768/GCC_CS/core_cm3.o ./mbed/LPC1768/GCC_CS/startup_LPC17xx.o
INCLUDE_PATHS = -I. -I./mbed -I./mbed/LPC1768 -I./mbed/LPC1768/GCC_CS
LIBRARY_PATHS = -L./mbed/LPC1768/GCC_CS
LIBRARIES = -lmbed -lcapi
LINKER_SCRIPT = ./mbed/LPC1768/GCC_CS/LPC1768.ld
GCC_BIN = /usr/bin/
PROJECT = Test_PPRZ_Datalink
OBJECTS = ./test_dl.o
SYS_OBJECTS = ./mbed/LPC1768/GCC_CS/sys.o ./mbed/LPC1768/GCC_CS/cmsis_nvic.o ./mbed/LPC1768/GCC_CS/system_LPC17xx.o ./mbed/LPC1768/GCC_CS/core_cm3.o ./mbed/LPC1768/GCC_CS/startup_LPC17xx.o
INCLUDE_PATHS = -I. -I./mbed -I./mbed/LPC1768 -I./mbed/LPC1768/GCC_CS
LIBRARY_PATHS = -L./mbed/LPC1768/GCC_CS
LIBRARIES = -lmbed -lcapi
LINKER_SCRIPT = ./mbed/LPC1768/GCC_CS/LPC1768.ld

CC = $(GCC_BIN)arm-none-eabi-gcc
CPP = $(GCC_BIN)arm-none-eabi-g++
CC_FLAGS = -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections
ONLY_C_FLAGS = -std=gnu99
ONLY_CPP_FLAGS = -std=gnu++98
CC_SYMBOLS = -DTARGET_LPC1768 -DTOOLCHAIN_GCC_CS -DNDEBUG
CC = $(GCC_BIN)arm-none-eabi-gcc
CPP = $(GCC_BIN)arm-none-eabi-g++
CC_FLAGS = -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections
ONLY_C_FLAGS = -std=gnu99
ONLY_CPP_FLAGS = -std=gnu++98
CC_SYMBOLS = -DTARGET_LPC1768 -DTOOLCHAIN_GCC_CS -DNDEBUG


### PPRZ Datalink ###
### PPRZ Datalink ###

PPRZ_DATALINK_PORT = Uart
PPRZ_DATALINK_DIR = .
include $(PPRZ_DATALINK_DIR)/datalink/pprz_datalink.mk
OBJECTS += $(PPRZ_DATALINK_OBJS)
CC_SYMBOLS += $(PPRZ_DATALINK_CFLAGS)
PPRZ_DATALINK_PORT = Uart
PPRZ_DATALINK_DIR = .
include $(PPRZ_DATALINK_DIR)/datalink/pprz_datalink.mk
OBJECTS += $(PPRZ_DATALINK_OBJS)
CC_SYMBOLS += $(PPRZ_DATALINK_CFLAGS)

#####################
#####################


AS = $(GCC_BIN)arm-none-eabi-as
AS = $(GCC_BIN)arm-none-eabi-as

LD = $(GCC_BIN)arm-none-eabi-gcc
LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc
LD = $(GCC_BIN)arm-none-eabi-gcc
LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc

OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy

all: $(PROJECT).bin
all: $(PROJECT).bin

clean:
rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS)
clean:
rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS)

.s.o:
$(AS) $(CC_FLAGS) $(CC_SYMBOLS) -o $@ $<
.s.o:
$(AS) $(CC_FLAGS) $(CC_SYMBOLS) -o $@ $<

.c.o:
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_C_FLAGS) $(INCLUDE_PATHS) -o $@ $<
.c.o:
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_C_FLAGS) $(INCLUDE_PATHS) -o $@ $<

.cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_CPP_FLAGS) $(INCLUDE_PATHS) -o $@ $<
.cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) $(ONLY_CPP_FLAGS) $(INCLUDE_PATHS) -o $@ $<


$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)

$(PROJECT).bin: $(PROJECT).elf
$(OBJCOPY) -O binary $< $@
```
$(PROJECT).bin: $(PROJECT).elf
$(OBJCOPY) -O binary $< $@
~~~

0 comments on commit 902768a

Please sign in to comment.