Go Down

Topic: Cosa: An Object-Oriented Platform for Arduino programming (Read 104317 times) previous topic - next topic

kowalski

@MarsWarrior

Thanks for all the info and especially the links. Always great to have a look at other implementations and approaches.

My guess on the MCP79141X device was not that bad. It is basically a MCP7940N with an EEPROM (128 bytes), an ID and some security register setup sequencing. The Cosa EEPROM driver for AT24CXX has the same I2C address (0x5X) and could be used for the EEPROM part. The security sequencing will need some tweaking.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/TWI/Driver/AT24CXX.hh

Cheers!

kowalski

#376
Jun 23, 2014, 09:03 pm Last Edit: Jun 24, 2014, 11:59 pm by kowalski Reason: 1
Some news on the latest Cosa updates:

1. TCS230 color sensor device driver
Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Driver/TCS230.hh
Example: https://github.com/mikaelpatel/Cosa/blob/master/examples/Sandbox/CosaTCS230/CosaTCS230.ino

2. Arduino String class
Refactoring of the Arduino String class and support for Cosa IOStream output operator with String.
Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/String.hh
Example: https://github.com/mikaelpatel/Cosa/blob/master/examples/Sandbox/CosaString/CosaString.ino

3. Removed offsetof() macro warning
Older version of AVR GCC will give warnings on usage of offsetof() macro.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Types.h#L154

4. MCP7940N Alarm interrupt handler and example sketch
The device driver supports alarm interrupts so that the MCU can power-down and wake up on a RTCC alarm. Both device alarms may be used to trigger a wake up. The device driver has been tested on Anarduino MiniWireless. A new example sketch is available. https://github.com/mikaelpatel/Cosa/blob/master/examples/Time/CosaMCP7940N/CosaMCP7940N.ino

5. Breaking the 30 KLOC barrier
The Cosa source code repository is 30+ KLOC without comments and 58+ KLOC with comments. This does not include the 150+ example sketches. Please see Ohloh for more details. https://www.ohloh.net/p/cosa

Cheers!

MarsWarrior

Just a question @kowalski:
As my intention is to base all my nodes on Cosa, some additional chip & functional support should be added to the Cosa eco system :smiley-red:

I guess the best way to make that visible is to add an issue on GitHub for each chip and/or function??

kowalski

#378
Jun 28, 2014, 11:29 am Last Edit: Jul 01, 2014, 07:02 pm by kowalski Reason: 1

As my intention is to base all my nodes on Cosa, some additional chip & functional support should be added to the Cosa eco system :smiley-red:
I guess the best way to make that visible is to add an issue on GitHub for each chip and/or function??

@MarsWarrior

That sounds like a good idea. The issue list on github is the right place for that.

There are a few things to consider. At this stage Cosa is not a commercial product or project as Arduino. There is no license, no registration, and no release handling with maintenance. The idea is to collaborate and build an industry strength high quality fully OOP alternative to the Arduino codebase. If and when we reach critical mass the next stage will offer release and maintenance.

For now anybody may contribute by building and test, writing code, donating hardware, giving improvement suggestions, etc. Contributing code requires normal open source git handling; clone/fork and pull request. The contributed code should follow the coding standard and must have test and/or example code. Contributed code will follow the normal refactoring of Cosa. The high level of refactoring right now is also part of the current stage.

Easiest way to get new device drivers is to contribute hardware. This is important even when contributing code to the main repository. It is difficult to add code that cannot be tested. This will need a lot of convincing :-).

Cheers!

Testato

- [Guida] IDE - http://goo.gl/ln6glr
- [Lib] ST7032i LCD I2C - http://goo.gl/GNojT6
- [Lib] PCF8574+HD44780 LCD I2C - http://goo.gl/r7CstH

kowalski

#380
Jul 01, 2014, 11:32 pm Last Edit: Jul 01, 2014, 11:58 pm by kowalski Reason: 1
The latest Cosa update includes porting and configuration of the Arduino-Makefile https://github.com/sudar/Arduino-Makefile. This allows simple build using "traditional" make files. To get started simply configure the build template with your Arduino installation path (https://github.com/mikaelpatel/Cosa/blob/master/build/Cosa.mk#L21) and write a three line makefile in the same directory as the sketch.

Code: [Select]

COSA_DIR = $(HOME)/Sketchbook/hardware/Cosa
BOARD_TAG = duemilanove
include $(COSA_DIR)/build/Cosa.mk


The COSA_DIR variable is the path of the Cosa installation. The BOARD_TAG is the type of board to build the sketch for. The possible board tags are:

Code: [Select]

BOARD_TAG DESCRIPTION
================================================================================
miniwireless Cosa Anarduino MiniWireless (ATmega328/BOOT_168)
duemilanove Cosa Arduino Duemilanove (ATmega328/BOOT_168)
leonardo Cosa Arduino Leonardo (ATmega32U4/Caterina)
mega Cosa Arduino Mega (ATmega2560/STK500v2)
nano Cosa Arduino Nano (ATmega328/BOOT_168)
pro-micro Cosa Arduino Pro Micro (ATmega32U4/Caterina)
pro-mini Cosa Arduino Pro Mini (ATmega328/BOOT_168)
pro-mini-8 Cosa Arduino Pro Mini (ATmega328/BOOT_168, 3.3V, 8 MHz)
uno Cosa Arduino Uno (ATmega328/Optiboot)
attiny84-8 Cosa Breadboard (ATtiny84, 8 MHz internal clock)
attiny85-8 Cosa Breadboard (ATtiny85, 8 MHz internal clock)
attiny861-8 Cosa Breadboard (ATtiny861, 8 MHz internal clock)
atmega328-8 Cosa Breadboard (ATmega328, 8 MHz internal clock)
mighty Cosa Breadboard (ATmega1284/BOOT_1284P)
mighty-opt Cosa Breadboard (ATmega1284/Optiboot)
lilypad Cosa LilyPad Arduino (ATmega328/BOOT_168, 8 MHz)
lilypad-usb Cosa LilyPad Arduino USB (ATmega32U4/Caterina, 8 MHz)
moteino Cosa LowPowerLab Moteino (ATmega328/DualOptiboot)
microduino-core Cosa Microduino-Core (ATmega328/Optiboot)
microduino-core32u4 Cosa Microduino-Core32u4 (ATmega32U4/Caterina)
microduino-core-plus Cosa Microduino-Core+ (ATmega644P/Optiboot)
pinoccio Cosa Pinoccio Scout (ATmega256RFR2/STK500v2)
teensy-2_0 Cosa Teensy 2.0 (ATmega32U4/halfkay)
teensypp-2_0 Cosa Teensy++ 2.0 (AT90USB1286/halfkay)


Build, upload and monitor the sketch with the following command.

Code: [Select]

make upload monitor


The Cosa Arduino-Makefile uses miniterm.py as serial monitor. The exit command is CTRL-ALT GR ]

Build for another board by either changing the BOARD_TAG in the Makefile or simply giving the command:

Code: [Select]

make "BOARD_TAG=uno"


More details in the Cosa/build directory and on the original Arduino-Makefile site. Please see the example makefiles in the CosaBlink and CosaBenchmarkPins directories.

Cheers!

kowalski

#381
Jul 02, 2014, 01:57 am Last Edit: Jul 05, 2014, 05:42 pm by kowalski Reason: 1
Command line build of Cosa based sketches is now as easy as it gets.  A new shell script (cosa)  eliminates the need for makefiles. Used as follows:
Code: [Select]
cosa BOARD COMMAND
Where BOARD is one of the BOARD_TAGs and COMMAND is what is passed to make (Arduino-Makefile). Typical usage are:

1. Some basic instructions on how to use the tool and make targets.
Code: [Select]

user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa help
Available targets (default is compile the code):
 upload            - upload
 ispload           - upload using an ISP
 raw_upload        - upload without first resetting
 eeprom            - upload the eep file
 raw_eeprom        - upload the eep file without first resetting
 clean             - remove all our dependencies
 depends           - update dependencies
 reset             - reset the Arduino by tickling DTR or changing baud
                     rate on the serial port.
 boards            - list all the boards defined in boards.txt
 config            - list configuration
 monitor           - connect to the Arduino's serial port
 size              - show the size of the compiled output (relative to
                     resources, if you have a patched avr-size).
 verify_size       - verify that the size of the final file is less than
                     the capacity of the micro controller.
 symbol_sizes      - generate a .sym file containing symbols and their
                     sizes.
 disasm            - generate a .lss file that contains disassembly
                     of the compiled file interspersed with your
                     original source code.
 generate_assembly - generate a .s file containing the compiler
                     generated assembly of the main sketch.
 burn_bootloader   - burn bootloader and fuses
 set_fuses         - set fuses without burning bootloader
 help_vars         - print all variables that can be overridden
 avanti            - short cut for upload and monitor
 help              - show this help
More details in:
/home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile/Arduino.mk
/home/user/Sketchbook/hardware/Cosa/build/Cosa.mk

2. Get the current configuration.
Code: [Select]

user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa uno config
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX
- [USER]               ARDMK_DIR = /home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile
- [USER]               ARDUINO_DIR = /home/user/opt/arduino-1.0.5
- [AUTODETECTED]       ARDUINO_VERSION = 105
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/user/.arduino/preferences.txt
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/user/Sketchbook (from arduino preferences file)
- [BUNDLED]            AVR_TOOLS_DIR = /home/user/opt/arduino-1.0.5/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /home/user/opt/arduino-1.0.5/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_CORE_PATH = /home/user/Sketchbook/hardware/Cosa/cores/cosa
- [USER]               ARDUINO_VAR_PATH = /home/user/Sketchbook/hardware/Cosa/variants
- [USER]               BOARDS_TXT = /home/user/Sketchbook/hardware/Cosa/boards.txt
- [DEFAULT]            USER_LIB_PATH = /home/user/Sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [USER]               BOARD_TAG = uno
- [COMPUTED]           OBJDIR = build-uno (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [DEFAULT]            MCU_FLAG_NAME = mmcu
- [DEFAULT]            CFLAGS_STD = -std=gnu99
- [AUTODETECTED]       DEVICE_PATH =  
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /home/user/opt/arduino-1.0.5/hardware/arduino/bootloaders (from ARDUINO_DIR)
-------------------------
Please refer to /home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile/Arduino.mk for more details.

3. Get a list of the available boards.
Code: [Select]

user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa boards
atmega328-8           Cosa Breadboard (ATmega328, 8 MHz internal clock)
attiny84-8            Cosa Breadboard (ATtiny84, 8 MHz internal clock)
attiny85-8            Cosa Breadboard (ATtiny85, 8 MHz internal clock)
attiny861-8           Cosa Breadboard (ATtiny861, 8 MHz internal clock)
duemilanove           Cosa Arduino Duemilanove (ATmega328/BOOT_168)
leonardo              Cosa Arduino Leonardo (ATmega32U4/Caterina)
lilypad               Cosa LilyPad Arduino (ATmega328/BOOT_168, 8 MHz)
lilypad-usb           Cosa LilyPad Arduino USB (ATmega32U4/Caterina, 8 MHz)
mega                  Cosa Arduino Mega (ATmega2560/STK500v2)
microduino-core32u4   Cosa Microduino-Core32u4 (ATmega32U4/Caterina)
microduino-core       Cosa Microduino-Core (ATmega328/Optiboot)
microduino-core-plus  Cosa Microduino-Core+ (ATmega644P/Optiboot)
mighty                Cosa Breadboard (ATmega1284/BOOT_1284P)
mighty-opt            Cosa Breadboard (ATmega1284/Optiboot)
miniwireless          Cosa Anarduino MiniWireless (ATmega328/BOOT_168)
moteino               Cosa LowPowerLab Moteino (ATmega328/DualOptiboot)
nano                  Cosa Arduino Nano (ATmega328/BOOT_168)
pinoccio              Cosa Pinoccio Scout (ATmega256RFR2/STK500v2)
pro-micro             Cosa Arduino Pro Micro (ATmega32U4/Caterina)
pro-mini-8            Cosa Arduino Pro Mini (ATmega328/BOOT_168, 3.3V, 8 MHz)
pro-mini              Cosa Arduino Pro Mini (ATmega328/BOOT_168)
uno                   Cosa Arduino Uno (ATmega328/Optiboot)

4. Build the CosaBenchmarkPins sketch for Arduino Uno, upload and start the serial monitor.
Code: [Select]

user@host:~/Sketchbook/hardware/Cosa/examples/Benchmarks/CosaBenchmarkPins$ cosa uno avanti


To install this new build feature please either add Cosa/build to your PATH or symbolic link from you local bin directory to the build script $COSA_DIR/build/cosa. The default path for COSA_DIR is $HOME/Sketchbook/hardware/Cosa. You can set COSA_DIR as an exported environment variable.

To use GNU Emacs as the Cosa IDE simply use the command M-X compile with "cosa BOARD upload" (only needed the first time per session). You can directly move to any compile error with M-X goto-next-locus. Add the following to your .emacs file to allow bind compile-upload to F2 and goto-next-error to F3. The first line below will make GNU Emacs recognize .pde/.ino files as C++ and automatically switch to the correct mode.  
Code: [Select]

(setq auto-mode-alist (cons '("\\.\\(pde\\|ino\\)$" . c++-mode) auto-mode-alist))
(global-set-key (quote [f2]) (quote compile))
(global-set-key (quote [f3]) (quote goto-next-locus))

Below is an example of compiling the CosaBlink example sketch with a bad modification and stepping to the error line (F2 and F3).

GNU Emacs will help you with indentation, quick incremental search,  color coding comments, etc. Together with the new Cosa build script GNU Emacs gives a productive IDE for Arduino programming that is easy to customize.  

The Arduino version is configured in the file Cosa/build/Cosa.mk. There is support for the following Arduino versions; 1.0.5, 1.5.6-r2 and the nightly build with GCC 4.8.1.

Cheers!

kowalski

#382
Jul 03, 2014, 10:10 pm Last Edit: Jul 03, 2014, 10:19 pm by kowalski Reason: 1
The latest update of Cosa includes a device driver for MAX7219/MAX7221 Serially Interfaced, 8-digit LED Display Drivers.

The device driver implements the Cosa LCD/IOStream::Driver interface. It handles carriage-return-line-feed, backspace, alert, horizontal tab and form-feed. The period character is translated to the 7-segment LED decimal point of the previous written character. The example sketch (https://github.com/mikaelpatel/Cosa/blob/master/examples/LCD/CosaMAX72XX/CosaMAX72XX.ino) shows how to output floating-point numbers to a Cosa IOStream.

Cheers!

Ref.
Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/LCD/Driver/MAX72XX.hh
Source: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/LCD/Driver/MAX72XX.cpp

kowalski

#383
Jul 06, 2014, 04:32 pm Last Edit: Jul 07, 2014, 12:17 am by kowalski Reason: 1
The latest update of the Cosa command line build script adds support for attiny devices. The below example command line will build the CosaBlink sketch for an ATtiny84 (internal clock 8 MHz) and upload with ISP device on the given port.
Code: [Select]

user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa attiny84-8 ispload ISP_PORT=/dev/ttyACM0

The command "cosa boards" lists the devices that require ISP device upload as "Cosa Breadboard" with the MCU and clock type/frequency. The default ISP device is defined as "arduino:arduinoisp" in the Cosa/boards.txt file.

The latest update also includes an updated version of miniterm.py (serial monitor) so that 1) the board may signal shutdown of the serial monitor and 2) LF/CR is handled correctly both for RX and TX to the board. The shutdown signal is used by the Cosa ASSERT macro and the Trace::fatal_P() member function on error detect. The ASSERT error message uses the same format as GCC compiler errors and warnings so that the M-X goto-next-locus (F3) command can be used in GNU Emacs to directly step to the ASSERT code line.

Cheers!

g_ad

Hello, I hope this is right place to ask the question. I have Mega1280 board and I don't know what should I choose in tools/boards. In the arduino ide there is mega1280, what would be equivalent in cosa?
Kind Regards,
Adam

kowalski


Hello, I hope this is right place to ask the question. I have Mega1280 board and I don't know what should I choose in tools/boards. In the arduino ide there is mega1280, what would be equivalent in cosa?
Kind Regards,
Adam

@g_ad

Hi Adam! Ok with the question here on the Arduino forum but you would get faster response on the Cosa github issues list. https://github.com/mikaelpatel/Cosa/issues?state=open

The current Mega 2560 support will not work for the Mega 1280 as this board has a different bootloader. To fix this I have added a board definition for the Mega 1280 to the Cosa boards definition file. Please download from github https://github.com/mikaelpatel/Cosa/archive/master.zip and install https://github.com/mikaelpatel/Cosa/blob/master/doc/02-install.md.

Cheers!


g_ad



Hello, I hope this is right place to ask the question. I have Mega1280 board and I don't know what should I choose in tools/boards. In the arduino ide there is mega1280, what would be equivalent in cosa?
Kind Regards,
Adam

@g_ad

Hi Adam! Ok with the question here on the Arduino forum but you would get faster response on the Cosa github issues list. https://github.com/mikaelpatel/Cosa/issues?state=open

The current Mega 2560 support will not work for the Mega 1280 as this board has a different bootloader. To fix this I have added a board definition for the Mega 1280 to the Cosa boards definition file. Please download from github https://github.com/mikaelpatel/Cosa/archive/master.zip and install https://github.com/mikaelpatel/Cosa/blob/master/doc/02-install.md.

Cheers!




@kowalski
Good news ans super fast response, thank you very much.
This is my beginning of the adventure with Cosa plaftorm :) The note is taken where to post questions :)
Kind regards,
Adam

kowalski


Good news ans super fast response, thank you very much.
This is my beginning of the adventure with Cosa plaftorm :) The note is taken where to post questions :)
Kind regards,
Adam

@g_ad
You are welcome. Please let me know how the update works with Arduino Mega 1280 as I do not have that specific board to test. As the MCU is very similar to the Mega 2560,  half the amount of program memory but otherwise the same, I believe that it should work just fine.

I have also added support for the Arduino Diecimila (https://github.com/mikaelpatel/Cosa/issues/209). All boards can be built with the command line tool.

Cheers!

g_ad

#388
Jul 14, 2014, 09:35 pm Last Edit: Jul 14, 2014, 09:41 pm by g_ad Reason: 1

@g_ad
You are welcome. Please let me know how the update works with Arduino Mega 1280 as I do not have that specific board to test. As the MCU is very similar to the Mega 2560,  half the amount of program memory but otherwise the same, I believe that it should work just fine.

I have also added support for the Arduino Diecimila (https://github.com/mikaelpatel/Cosa/issues/209). All boards can be built with the command line tool.

Cheers!


@kowalski
I can confirm, Mega1280 is working now :), however it seems that the uart1 doesn't work, I've tried the MegaUARTs example and had to change to uart2 to test it.

Time to get my head around to understand the software, as I'm rather beginner than advanced - it will take some time.

Kind regards,
Adam

kowalski


@kowalski
I can confirm, Mega1280 is working now :), however it seems that the uart1 doesn't work, I've tried the MegaUARTs example and had to change to uart2 to test it.

@g_ad
Thanks for the info. Great that you got your Mega 1280 board up and running with Cosa. I will look into the UART numbering. Seems like the ISRs might have got mixed up.

Cheers!

Go Up