Jump to content

madias

Members
  • Content Count

    49
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    madias reacted to spirilis in Strange behavior pinMode/digitalWrite within library   
    Yes that will happen with Energia 12- it was fixed in Energia 13. If you must keep E12 just copy hardware/lm4f/cores/lm4f/main.cpp and startup_gcc.c from Energia 13 over for the fix. Note this same bug exists on the CC3200 in Energia 13, fix will appear in Energia 14 for that arch.
  2. Like
    madias reacted to igor in howto: porting libraries - some help needed   
    5. Working on multiple platforms.  There are various macros to help select appropriate code for the current platform.
     
    Environment/library
    ENERGIA - Energia environment (Tiva/CC3200/MSP430/C2000 )
    CORE_TEENSY - TeensyDuino (AVR/ )
    MAPLE_IDE - libmaple (STM32)
    MPIDE - chipKIT
    ARDUINO - (AVR/SAM/x86/...) - also defined by other environments, like ENERGIA.
     
    Processor family:
    __MSP430_CPU__ or __MSP430_HEADER_VERSION__ - MSP430
    [???] - MSP432
    __arm__ - Should be true for any ARM processor (e.g. Tiva, Stellaris, CC3200, SAM/Arduino Due, STM32, Freescale, ... )
    __AVR__ - Atmel AVR processors (original Arduino, Teensy before version 3, etc.)
    __ARDUINO_X86__ - Intel x86/Galileo
     
    Board: (Arduino 1.5.7 BETA)
    ARDUINO_SAM_DUE - Arduino Due
    ARDUINO_AVR_xxx (YUN, LEONARDO, MEGA, ....) - Various AVR Arduinos
     
    see for example
    Embededxcode: Manage code for multiple platforms
     
    Additional examples and information:
    http://forum.stellarisiti.com/topic/1965-architecture-for-conditional-compilation-in-energia/
    http://forum.43oh.com/topic/5670-one-sketch-multiple-architectures/
     
    [Edit: Oct 1 2014: Added Board, added x86 processor]
    [Edit: Need to add MSP432]
  3. Like
    madias reacted to igor in howto: porting libraries - some help needed   
    0. If want to maintain backwards compatibility (one library to run on both Arduino and LM4F)
    #if defined(__AVR__) //Leave the AVR arduino code as is #else //alternative code for LM4F #endif 1.1
    Can just leave those include statements as is, Arduino.h includes Energia.h
     
     
    2. 
    #if !defined(__AVR__) #if !defined(PROGMEM) #define PROGMEM #define memcpy_P(dest, src, len) memcpy((dest), (src), (len)) #endif #if (13 == ENERGIA) // Energia version 13 pgm_read_byte and pgm_read_dword do not work under some circumstances. #undef pgm_read_byte #undef pgm_read_dword #endif #ifndef pgm_read_byte #define pgm_read_byte(x) (*(const unsigned char *)(x)) #endif #ifndef pgm_read_dword #define pgm_read_dword(x) (*(const unsigned long *)(x)) #endif #endif 4.2
    digitalPinToPort, digitalPinToBitMask, digitalPinToTimer - these all exist in Energia.h 
    (Not sure if need any conversion, depends how the result is used)
     
    portOutputRegister - consider/compare to Energia portDATARegister
     
     
    But, if you want to take better advantage of the capabilities of the Stellaris/Tiva processors you could do something like this.
    #define portMaskedOutputRegister(port, mask) \   ((volatile uint8_t *) (((uint32_t)portBASERegister(port)) + (GPIO_O_DATA + (((uint32_t)mask) << 2)))) The mask you supply will be applied before writing to the port in question, so one does not have to do read the
    port, twiddle the bit(s) of interest, write it back.  Can just write it, and only the bits indicated by the mask will be changed.
    So 
    oepin     = digitalPinToBitMask(oe); oeport    = portOutputRegister(digitalPinToPort(oe)); *oeport    |= oepin; *oeport    &= ~oepin; // can become oepin     = digitalPinToBitMask(oe); oeport    = portMaskedOutputRegister(digitalPinToPort(oe), oepin); *oeport    = 0xFF; *oeport    = 0; Note that in the bit set example, you could use oepin in place of 0xFF, however if you are writing 1's to several ports
    in nearby code, the compiler may be able to keep the one value in a register, rather than having to load a bunch of
    different port masks.  (Also, the original AVR code will still work, it just takes more instructions.)
     
    If you define a mask which selects several pins, you can output to them all together with a single write, e.g.
    *rowport = row; // Add bit shifts as needed if the pins for row do not start at pin 0 Rather than having to split row up one bit at a time.
     
    Edited August 2014 - add parenthesis around parameters in PROGMEM, add test to be sure PROGMEM not already defined.
    [Edited November 2014 - updated definitions of pgm_read_byte.  Replace versions from Energia 13 which don't work right.]
  4. Like
    madias got a reaction from jhonys1 in [Energia Library] Stellaris Launchpad FatFs Energia library   
    Ok, so I guess there are 3 "main libraries/wrappers" to use with tiva/stellaris:
    FatFs
    Petit FatFs (lightweight of FatFs)
    and  Sd2Card (original distributed with the Arduino IDE)
     
    I did a quick&dirty port of the Sd2Card Library, taken out of Arduino IDE 1.5.6 r2 for the Tiva/Stellaris, only changed some ARM settings, especially in the Sd2PinMap.h file: (at the top of the "arm" section): 
    uint8_t const SS_PIN = 32; uint8_t const MOSI_PIN = 8; uint8_t const MISO_PIN = 13; uint8_t const SCK_PIN = 11; because I need SPI Module(0)
    While in use don't forget to set in "Setup": 
    SPI.setModule(0);
    and get rid of the 
    while (!Serial) {     ; // wait for serial port to connect. Needed for Leonardo only   } lines in the examples and set up the CS Pin. Now many of Arduino written sketches will work right out of the box!   Todo: more convenient selecting the SPI module and CS Pin, like  SD.begin(CS_Pin,Module) Attach Files:
    SD.zip = Port of the Arduino SDCard Library
    SD2Card_Tiva_examples.zip: some examples
    SD.zip
    SD2Card_Tiva_examples.zip
  5. Like
    madias got a reaction from StrangerM in [Energia Library] ILI9341 TFT 2.2 port   
    Ok, I've merged the newer version of the seeed library with the energia port.
    Text rotation is now possible, but very disappointing and bad integrated, but for my purposes it works.
    Note that the background color of the text wont work anymore, I've included a dummy variable for compatibility reasons. 
    Modification and an example attached.
    ILI9341_energia 2.zip
  6. Like
    madias got a reaction from bluehash in Kernel Panic under OSX 1.9.2 on Macbook Pro 2009   
    Ok, found a "workaround": Not using any "Serial.xxx" in the sketch wouldn't crash energia. 
    What a wonderful thing while debugging :/
  7. Like
    madias got a reaction from bluehash in Little helper script: Which timer is in use (Timer,Wtimer,Watchdog)?   
    Hello,
    as I was studying the (extremely good written!) driverlib documentation, i noticed the SysCtlPeripheralReady function.
    Because it is not always clear which Timer (TIMER,WTIMER,WATCHDOG) is currently in use (many of them are used with PWM and other stuff), I wrote this little helper sketch for my Tiva C.
    The definitions for other peripheral  can be read in "sysctl.h", I only used the timers to keep it short.
    I also included the SysCtlPeripheralPresent function, but I think it is meant, that a peripheral is physically available, so the "ready" function is the key. Try it out with some line of code with PWM stuff (with different pins) for example and see the difference!
    /* Little timer state helper no (c) by Matthias Diro */ #include <stdint.h> #include <stdbool.h> #define PART_TM4C123GH6PM #include "inc/tm4c123gh6pm.h" #include "driverlib/sysctl.h" void setup() { Serial.begin(9600); } void loop() { Serial.println("---Timertest---"); Serial.println("***Timer***"); for (int x=0;x<=5;x++) { Serial.print("Timer: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026532864+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026532864+x)); } Serial.println("***WTimer***"); for (int x=0;x<=5;x++) { Serial.print("WTimer: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026555392+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026555392+x)); } Serial.println("***Watchdogs***"); for (int x=0;x<=1;x++) { Serial.print("Watchdog: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026531840+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026531840+x)); } Serial.println(); while(1); } Maybe this little code helps some of you!
     
    Regards
    Matthias
  8. Like
    madias got a reaction from energia in Little helper script: Which timer is in use (Timer,Wtimer,Watchdog)?   
    Hello,
    as I was studying the (extremely good written!) driverlib documentation, i noticed the SysCtlPeripheralReady function.
    Because it is not always clear which Timer (TIMER,WTIMER,WATCHDOG) is currently in use (many of them are used with PWM and other stuff), I wrote this little helper sketch for my Tiva C.
    The definitions for other peripheral  can be read in "sysctl.h", I only used the timers to keep it short.
    I also included the SysCtlPeripheralPresent function, but I think it is meant, that a peripheral is physically available, so the "ready" function is the key. Try it out with some line of code with PWM stuff (with different pins) for example and see the difference!
    /* Little timer state helper no (c) by Matthias Diro */ #include <stdint.h> #include <stdbool.h> #define PART_TM4C123GH6PM #include "inc/tm4c123gh6pm.h" #include "driverlib/sysctl.h" void setup() { Serial.begin(9600); } void loop() { Serial.println("---Timertest---"); Serial.println("***Timer***"); for (int x=0;x<=5;x++) { Serial.print("Timer: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026532864+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026532864+x)); } Serial.println("***WTimer***"); for (int x=0;x<=5;x++) { Serial.print("WTimer: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026555392+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026555392+x)); } Serial.println("***Watchdogs***"); for (int x=0;x<=1;x++) { Serial.print("Watchdog: "); Serial.print(x); Serial.print(" present: "); Serial.print(SysCtlPeripheralPresent(4026531840+x)); Serial.print(" ready: "); Serial.println(SysCtlPeripheralReady(4026531840+x)); } Serial.println(); while(1); } Maybe this little code helps some of you!
     
    Regards
    Matthias
  9. Like
    madias got a reaction from Thorvard in [Energia Library] Stellaris Launchpad FatFs Energia library   
    @@Rei Vilo:
    Maybe you can really post your SD library (is it really for stellaris/tiva?), I see a lot of things to do with the original one, so you can save much work for  Thorvard and me
     
    Thank you 
    Regards 
    Matthias
  10. Like
    madias got a reaction from igor in howto: porting libraries - some help needed   
    Hello,
    I'm trying to collect some standard procedures porting arduino(mostly avr, sam is easier) libraries to energia/lm4f. 
    Maybe all forum members could help together, creating a little howto:
     
    Porting libraries to Energia/Stellaris LM4F
    Version 2014-05-20
     
    1. First, it is necessary to examine the files to the following:
     
    1.1
    #if ARDUINO >= 100
    #include <Arduino.h> 
    #else
    #include <WProgram.h> 
    #endif
     
    and change it to:
    #include <Energia.h> 
    (or let #include <Arduino.h> as only line)
     
    1.2 change #include <pins_arduino.h> to #include <pins_energia.h>
     
    2. If PROGMEM was used:
    remove all PROGMEM and replace pgm_read_byte with *
    and better add a static const
     
    or insert this line on top: (Untested)
    #define PROGMEM
    #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
     
    or insert:(Untested)
    #define pgm_read_word(data) *(data)
    #define pgm_read_byte(data) *(data)
    #define PROGMEM
     
    3. __delay_cycles macro
    3.1 easy way: use delayMicroseconds(xxx) where xxx is to try&error
    3.2 use SysCtlDelay(xxx); -> Thread: http://forum.stellarisiti.com/topic/1980-delay-cycles/
     
    4. Pin related macros/stuff
     
    4.1 insert:(Untested)
    #define cbi(reg, mask) GPIOPinWrite(reg, mask, 0)
    #define sbi(reg, mask) GPIOPinWrite(reg, mask, mask)
    #define pulse_high(reg, bitmask) { sbi(reg, bitmask); cbi(reg, bitmask); }
    #define pulse_low(reg, bitmask) { cbi(reg, bitmask); sbi(reg, bitmask); }
     
    4.2 Conversation: (now I need your help for converting!)
    Arduino / AVR:
    #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
    #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
    #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
    #define analogInPinToBit(P) (P)
    #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
    #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
    #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
     
    So your help is desired, I'll update this thread as soon as I get new information.
    Maybe we can build together a conversation.h file, so we can include it to every library (for testing)
     
    Regards 
    Matthias
  11. Like
    madias reacted to energia in Kernel Panic under OSX 1.9.2 on Macbook Pro 2009   
    I plan to replace RXTX with JSSC in the next release.
×
×
  • Create New...