Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gamelaster committed Dec 6, 2020
0 parents commit 9c1b2d2
Show file tree
Hide file tree
Showing 33 changed files with 4,778 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tools/*
503 changes: 503 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
menu.UploadSpeed=Upload Speed


###########

pinecone.name=PINE64 PineCone

pinecone.upload.tool=flasher
pinecone.upload.maximum_size=1310720
pinecone.upload.maximum_data_size=327680
pinecone.upload.wait_for_upload_port=true

pinecone.serial.disableDTR=true
pinecone.serial.disableRTS=true

pinecone.build.mcu=bl602
pinecone.build.core=bl602
pinecone.build.variant=pinecone
pinecone.build.board=PINECONE_EVB

# pinecone.build.f_cpu=240000000L
# pinecone.build.flash_size=4MB
# pinecone.build.flash_freq=40m
# pinecone.build.flash_mode=dio
# pinecone.build.boot=dio
# pinecone.build.partitions=default
# pinecone.build.defines=

pinecone.menu.UploadSpeed.2000000=2000000

# pinecone.menu.UploadSpeed.921600=921600
# pinecone.menu.UploadSpeed.921600.upload.speed=921600
# pinecone.menu.UploadSpeed.115200=115200
# pinecone.menu.UploadSpeed.115200.upload.speed=115200
# pinecone.menu.UploadSpeed.256000.windows=256000
# pinecone.menu.UploadSpeed.256000.upload.speed=256000
# pinecone.menu.UploadSpeed.230400.windows.upload.speed=256000
# pinecone.menu.UploadSpeed.230400=230400
# pinecone.menu.UploadSpeed.230400.upload.speed=230400
# pinecone.menu.UploadSpeed.460800.linux=460800
# pinecone.menu.UploadSpeed.460800.macosx=460800
# pinecone.menu.UploadSpeed.460800.upload.speed=460800
# pinecone.menu.UploadSpeed.512000.windows=512000
# pinecone.menu.UploadSpeed.512000.upload.speed=512000
75 changes: 75 additions & 0 deletions cores/bl602/Arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef Arduino_h
#define Arduino_h

#include <FreeRTOS.h>
#include <task.h>

#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <math.h>

#ifdef __cplusplus
extern "C" {
#endif
extern TaskHandle_t rtosMainTask;
#include "bl602-hal-misc.h"
#include "bl602-hal-gpio.h"
#include "bl602-hal-pwm.h"
#ifdef __cplusplus
}
#endif

#include "binary.h"

#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105
#define EULER 2.718281828459045235360287471352

#define SERIAL 0x0
#define DISPLAY 0x1

#define LSBFIRST 0
#define MSBFIRST 1

#define bit(b) (1UL << (b))
#define _BV(b) (1UL << (b))

typedef bool boolean;
typedef uint8_t byte;
typedef unsigned int word;

void setup(void);
void loop(void);

#include "WString.h"
#include "Stream.h"
#include "Printable.h"
#include "Print.h"
#include "HardwareSerial.h"

#endif
63 changes: 63 additions & 0 deletions cores/bl602/HardwareSerial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2020 Marek Kraus <[email protected]>

#include "HardwareSerial.h"
extern "C" {
#include <bl_uart.h>
};

HardwareSerial Serial(0);

void HardwareSerial::begin(unsigned long baud, uint8_t config)
{
//bl_uart_flush(this->_uart_num);
bl_uart_init(_uart_num, 16, 7, 255, 255, baud);
//bl_uart_int_enable(this->_uart_num);
}

void HardwareSerial::end()
{
bl_uart_int_disable(_uart_num);
// TODO: ?
}

int HardwareSerial::available()
{
return UART_GetRxFifoCount((UART_ID_Type)_uart_num);
}

int HardwareSerial::peek()
{
// TODO:
return 0;
}

int HardwareSerial::read()
{
return bl_uart_data_recv(_uart_num);
}

int HardwareSerial::availableForWrite()
{
// TODO:
return 0;
}

void HardwareSerial::flush()
{
bl_uart_flush(_uart_num);
}

size_t HardwareSerial::write(uint8_t c)
{
bl_uart_data_send(_uart_num, c);
return 1;
}

size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
{
for (size_t i = 0; i < size; i++) {
bl_uart_data_send(_uart_num, buffer[i]);
}
return size;
}
63 changes: 63 additions & 0 deletions cores/bl602/HardwareSerial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2020 Marek Kraus <[email protected]>

#ifndef HardwareSerial_h
#define HardwareSerial_h

#include <inttypes.h>

#include "Stream.h"

// TODO:
#define SERIAL_8N1 0

class HardwareSerial : public Stream
{
public:
HardwareSerial(uint8_t uart_num) : _uart_num(uart_num) {};
void begin(unsigned long baud, uint8_t config=SERIAL_8N1);
void end();
int available();
int peek();
int read();
size_t read(uint8_t *buffer, size_t size);
inline size_t read(char * buffer, size_t size)
{
return read((uint8_t*) buffer, size);
}
int availableForWrite();
void flush();
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
inline size_t write(const char * buffer, size_t size)
{
return write((uint8_t*) buffer, size);
}

inline size_t write(unsigned long n)
{
return write((uint8_t) n);
}
inline size_t write(long n)
{
return write((uint8_t) n);
}
inline size_t write(unsigned int n)
{
return write((uint8_t) n);
}
inline size_t write(int n)
{
return write((uint8_t) n);
}
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool() const { return true; }
protected:
uint8_t _uart_num;
};

extern HardwareSerial Serial;

extern void serialEventRun(void) __attribute__((weak));

#endif
Loading

0 comments on commit 9c1b2d2

Please sign in to comment.