Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- GerritPathuis
- Date:
- 2018-02-17
- Revision:
- 3:19a244789b2b
- Parent:
- 2:329d3f88af27
- Child:
- 4:1249c317e7f3
File content as of revision 3:19a244789b2b:
#include "mbed.h"
#include "MODSERIAL.h"
// E45-TTL-100 RADIO------KL25Z
// AUX--------------------PTD4
// M1---------------------PTA12
// M0---------------------PTA4
// RXD--------------------PTE22(TX)
// TXD--------------------PTE23(RX)
// LORA Radio Transmits @ 868 mHz
// Expected range 2000m
// https://quadmeup.com/wp-content/uploads/2017/09/E45-TTL-100_Datasheet_EN_v1.2.pdf
Ticker timer;
MODSERIAL pc(USBTX, USBRX, 512); // tx, rx of the pc, (512 char buffer)
MODSERIAL e45(PTE22, PTE23, 512); // tx, rx of the E45 radio (512 char buffer)
InterruptIn aux(PTD4); // AUX the E45 radio
DigitalOut m1(PTA12,PullUp); // M1 the E45 radio
DigitalOut m0(PTA4, PullUp); // M0 the E45 radio
DigitalOut myled(LED_BLUE); // KL25x BLUE led
void flank_up()
{
myled=1; //Rising Edge Detected
}
void flank_down()
{
myled=0; //Falling Edge Detected
}
void timer_func() // Send something every 3 seconds
{
if (myled == 1) { // AUX is high (Buffer empty), send something
wait_ms(3);
e45.puts("123");
while(myled==0) {
pc.puts("Wait for end Transmission\n\r");
wait_ms(1);
}
pc.puts("\n\rRadio has sent 123\n\r");
}
}
int main()
{
int count=0;
pc.baud(115200);
e45.baud(9600); // Default for E45
e45.format(8, SerialBase::None, 1); // Default for E45
pc.puts("\n\r\nE45-TTL-100 LORA\n\r");
aux.rise(&flank_up); //Service RISING EDGE Interrupt
aux.fall(&flank_down); //Service FALLING EDGE Interrupt
// select mode
// Transparant Transmission
if (myled ==1) { //Check ready or not
while(myled==0) { //Wait when not yet ready
count++;
if (count > 2000000) {
count=0;
pc.puts("Wait for AUX Rising edge ");
}
}
}
wait_ms(2);
m0= 0; //Set transparant mode
m1= 0; //Set transparant mode
wait_ms(1);
pc.puts("E45 is now ready to send and receive \n\r");
timer.attach(&timer_func, 3.0);
while(1) {
if (myled == 0) { // AUX is low, Chars received
while(myled==0) {
if (e45.readable()) {
pc.putc(e45.getc()); //send to pc
}
}
}
}
}