<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Library porting question (PS2X_lib)</title>
		<link>http://forums.leaflabs.com/topic.php?id=2428</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:13:40 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=2428" rel="self" type="application/rss+xml" />

		<item>
			<title>crenn on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-22080</link>
			<pubDate>Wed, 23 Jan 2013 06:21:40 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">22080@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The digitalPinToPort function would need to give a 32-bit address than the 8 bit address that you'd normally expect. It might be possible to have a 'Arduino.h' compatibility layer, but then you're having to write code to emulate some AVR functions as writing to pins isn't as straight forward with the STM32 compared with the AVR.&#60;/p&#62;
&#60;p&#62;There is only 4 mentions of that function, and it's in the begin function.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gsentlin on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-22064</link>
			<pubDate>Mon, 21 Jan 2013 12:05:23 +0000</pubDate>
			<dc:creator>gsentlin</dc:creator>
			<guid isPermaLink="false">22064@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;This is not a PS2X_lib question, rather a library porting one.  I found this page by googling digitalPinToPort.  I'm trying to port the Adafruit_SSD1306 library over to Maple.  I found the port for GlcdSt7565Maple, which had many of the required libraries.  However, this compiling error:&#60;br /&#62;
 error: 'digitalPinToPort' was not declared in this scope&#60;br /&#62;
refers to functions found in Arduino.h.  Rather than going through the SSD1306 library and replacing all of these functions, it would seem more progressive is somebody ported the basic functionality found in Arduino.h.  Has this been attempted, or am I missing something?&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12885</link>
			<pubDate>Sun, 26 Aug 2012 05:08:10 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12885@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks!  I will give it a shot right now. I really appreciate your effort on this.  I found out that it needs to be mode3, but I guess the delay bit did not catch my attention.&#60;/p&#62;
&#60;p&#62;My project is coming along quite nicely.  The bit-banging of the controller works, but it does introduce some overhead that gets to be annoying when also controlling the motors.  I am am finding myself more and more impressed with this board the more I play with it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12878</link>
			<pubDate>Sat, 25 Aug 2012 20:44:08 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">12878@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I just got the PSX controller (It's generic) working with the Maple's Hardware SPI at SPI_562_500KHZ, SPI_281_250KHZ, and SPI_140_625KHZ. I didn't try any other speeds. Part of the problem I found was the delay between sending bytes was too short for the maple (maybe for the Arduino, these delays are longer for some reason, but won't go into it) and the delay of 15uS between bytes allowed it to work at higher speeds. The reason why this happens is because in a playstation, there is 1 more signal it needs, the acknowledgement signal. It flags when the controller is ready for more data, in all of these examples/libraries, it's not waiting for that and is setting a delay for long enough to allow the controller to be ready. It's also not known why there needs to be a longer delay for the higher clock speeds, however it's not something I'm going to investigate since I've had this hardware longer than I should have (I was only meant to borrow it for a weekend previously, but had it longer due to other commitments with university).&#60;/p&#62;
&#60;p&#62;Also, When I read the original code again, I realised that the controller wants SPI Mode 3 (clock line idle high and samples taken on rising edges). This was an error because I didn't have access to some reference material at the time I originally looked at it.&#60;/p&#62;
&#60;p&#62;Lastly, the circuitry I'm using will be slightly different to yours as the breakout board I borrowed contains a 74HC541N to buffer the signals between the original board it was designed for (a Digilent Spartan 3E Starter Board) and the controller. However, this should not affect the library working for you. There is still a bit of code cleanup to do, but this is the library:&#60;br /&#62;
&#60;a href=&#34;https://github.com/crenn/PS2X_lib_maple&#34; rel=&#34;nofollow&#34;&#62;https://github.com/crenn/PS2X_lib_maple&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12488</link>
			<pubDate>Fri, 17 Aug 2012 03:48:49 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12488@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Finally!   :)    Proof that you always win if you shoot enough bullets down range.  &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://lh6.googleusercontent.com/-S6nFZf4kArw/UC4EFYImEmI/AAAAAAAAB1k/rJpTvAGNwuA/s800/Screen%2520Shot%25202012-08-17%2520at%252001.41.13.png&#34; rel=&#34;nofollow&#34;&#62;https://lh6.googleusercontent.com/-S6nFZf4kArw/UC4EFYImEmI/AAAAAAAAB1k/rJpTvAGNwuA/s800/Screen%2520Shot%25202012-08-17%2520at%252001.41.13.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I had to bit-bang this for some reason.  Using the exact same pins and hardware configuration, the hardware SPI will not work.  It might have something to do with the pin mode, or it might be due to the fact that it is running slightly faster.  With a 1-microsecond delay between clock transitions, the controller still talks just fine to the Maple, even though the clock is nowhere near a 50% duty cycle.  :)  Even with a 1µS delay, it is still 9% slower than the slowest hardware mode.  That could very well be the reason why it won't work.&#60;/p&#62;
&#60;p&#62;Thank you guys so much for the assistance.  Now I get to work on other elements of this project.  :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12481</link>
			<pubDate>Fri, 17 Aug 2012 00:44:32 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12481@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;So close I can taste it!&#60;/p&#62;
&#60;p&#62;So, apparently hardware SPI still requires software control of SPI SS.  &#38;gt;_&#38;lt;&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;spi.begin(SPI_140_625KHZ, LSBFIRST, 2);
    pinMode(SPIss,OUTPUT);
    digitalWrite(SPIss,HIGH&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;With that done, SS does not bounce around and works as expected.  Sadly I cannot figure out MISO.  The PS2 controller does not apply any voltage to any of the SPI lines, so MISO has to be tied to Vcc with a pull up resistor.  I have tried everything from 1K (too small) to 10K (too big).  I cannot find a happy medium.  The first byte back from the controller should be FF when doing a read (in screenshot).  The data being sent over MOSI matches what I have the program sending, but MISO seems to be getting feedback from the clock line (likely because it runs parallel next to the clock line on the Arduino that is acting as the logic analyzer).  It seems like the controller is not pulling the line to ground like it should be.  Maybe my data rate is still too high for it to talk.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://lh4.googleusercontent.com/-WKqxj-gFCC4/UC3YrUjlUzI/AAAAAAAAB1M/U9UuMVRV3FM/s800/Screen%2520Shot%25202012-08-16%2520at%252022.37.17.png&#34; rel=&#34;nofollow&#34;&#62;https://lh4.googleusercontent.com/-WKqxj-gFCC4/UC3YrUjlUzI/AAAAAAAAB1M/U9UuMVRV3FM/s800/Screen%2520Shot%25202012-08-16%2520at%252022.37.17.png&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12477</link>
			<pubDate>Thu, 16 Aug 2012 22:04:28 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12477@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am starting to suspect a problem with SPI2.  NSS should be driven actively high or low, but with a 10M pullup  or pulldown resistor, the output never changes.  This is why I am seeing erratic behavior on the analyzer, there is noise on the line causing the floating line to bounce between high and low with the nearby line (MOSI).   I am at a loss now as to what to try next, other than try SPI1 at 280 kHz since apparently the 140kHz mode isn't working on SPI1 from what the docs say.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12474</link>
			<pubDate>Thu, 16 Aug 2012 21:01:23 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12474@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If I tie SS to ground or Vcc via a 10M resistor, I get expected data back from the logic analyzer when using hardware SPI on SPI2 (pins 31-34).  Not sure if SS is supposed to be bouncing all over the place like it is.  Either way, the resistor forces SS high or low and the controller obviously will not respond.   :(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12471</link>
			<pubDate>Thu, 16 Aug 2012 19:39:13 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12471@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;OK, making progress.&#60;/p&#62;
&#60;p&#62;I cannot tell if the analyzer I have is buggy when sampling at 1MHz, or if the Maple really is spitting out the incorrect data.&#60;/p&#62;
&#60;p&#62;I am sending the following to the controller...&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;byte enter_config[]={0x01,0x43,0x00,0x01,0x00};      followed by
byte set_mode[]={0x01,0x44,0x00,0x01,0x03,0x00,0x00,0x00,0x00};&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;As you can see, the '1' bit in the first byte is getting lost, according to the SPI analyzer.&#60;br /&#62;
&#60;a href=&#34;https://lh3.googleusercontent.com/--JmXo4Kf2lU/UC2RXf8ER1I/AAAAAAAAB04/eh8AiETb6C0/s800/Screen%2520Shot%25202012-08-16%2520at%252017.30.51.png&#34; rel=&#34;nofollow&#34;&#62;https://lh3.googleusercontent.com/--JmXo4Kf2lU/UC2RXf8ER1I/AAAAAAAAB04/eh8AiETb6C0/s800/Screen%2520Shot%25202012-08-16%2520at%252017.30.51.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;But it LOOKS like there is a '1' in there... so maybe it is the analyzer.  Either way, not getting useable data back from the controller yet.  I'll keep hammering away at it.  :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428&amp;page=2#post-12469</link>
			<pubDate>Thu, 16 Aug 2012 16:57:20 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12469@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Finally gave in and hooked up my ghetto Arduino based logic analyzer.&#60;/p&#62;
&#60;p&#62;I am bit-banging the SPI since I couldn't get the hardware SPI to produce any data, possibly due to being too fast.&#60;/p&#62;
&#60;p&#62;I am using about 20 µS per clock cycle and only getting a few bits back from the controller, but hey, progress.  :)&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://lh4.googleusercontent.com/-lF6lx_QodEQ/UC1sZlUkhnI/AAAAAAAAB0k/yGyl2Tj-Hl0/s800/Screen%2520Shot%25202012-08-16%2520at%252014.51.21.png&#34; rel=&#34;nofollow&#34;&#62;https://lh4.googleusercontent.com/-lF6lx_QodEQ/UC1sZlUkhnI/AAAAAAAAB0k/yGyl2Tj-Hl0/s800/Screen%2520Shot%25202012-08-16%2520at%252014.51.21.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Quite a bit wrong with my timing, so I'm going to look at my code a little more closely.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428#post-12460</link>
			<pubDate>Wed, 15 Aug 2012 21:03:42 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12460@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well, the issue with double precision floats on Arduino was that they weren't double precision.  :)   I was running into problems with objects being calculated almost 2 arc minutes away from where they should have been, vs a few arc seconds when running my code on my macbook.  :(&#60;/p&#62;
&#60;p&#62;Right now I am trying really hard to get my controller to talk to my Arduino.  I am using hardware SPI on port 2, and LSBFIRST, tried all 4 modes on the lowest three SPI speeds (i think 500KHz is max for controller).  I cannot read a single byte from the controller.&#60;/p&#62;
&#60;p&#62;I am going to try moving it back to SPI 1 and running at about  250kHZ, maybe something is up with port2.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428#post-12456</link>
			<pubDate>Wed, 15 Aug 2012 19:51:57 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">12456@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If I recall someone made a library for use and the crystal already on the maple. This can be seen here:&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=1058&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=1058&#60;/a&#62;&#60;br /&#62;
And can be downloaded here:&#60;br /&#62;
&#60;a href=&#34;https://github.com/bubulindo/MapleRTC&#34; rel=&#34;nofollow&#34;&#62;https://github.com/bubulindo/MapleRTC&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;With a compiler, you don't have to worry about the implementation of floating point maths in your code, you just write your program using float variables the and compiler does the rest. Moving from an arduino to a maple is certainly an upgrade!&#60;/p&#62;
&#60;p&#62;I got a loan of a PSX controller for the weekend so I'll see if I can't whip something up that will work for you, I can't guarantee it will work though. But at least I should be able to test it on some hardware. I'll see if I can get it working by Saturday (I have a bit on my plate the next couple of days including today) and give you some code to test.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428#post-12447</link>
			<pubDate>Wed, 15 Aug 2012 12:36:58 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12447@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crenn,&#60;/p&#62;
&#60;p&#62;I saw that the chip has an RTC, but I am not certain how I'd access it.  I did a little reading but came up empty handed.  I would obviously need an external oscillator, but god knows how to access the RTC after the hardware bits have been taken care of. &#60;/p&#62;
&#60;p&#62;Regarding the floating point, my skill with C is still in its infancy so trying to work around the 8bit in software was going to be a bit of a hassle.  Unfortunately with most of the astrodynamics formulas, we end up using Julian dates which themselves need several significant figures.  Granted, I could make it work, but I thought that I would give the Maple a try since the system is obviously an upgrade in many ways.  :)&#60;/p&#62;
&#60;p&#62;It would be really nice of you to take a shot at the PS2 controller.  I would love to contribute to this community, but I feel that the code that I'd produce would be scary at best.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428#post-12440</link>
			<pubDate>Wed, 15 Aug 2012 07:38:14 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">12440@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'll see if I can't borrow a PS2X controller from my uni (in a project, I had to implement a SPI interface for a microblaze core in VHDL) for a weekend and see what I can do. Although I might be a little busy since I'm helping my uni do an open day by doing a student panel and talking about the uni.&#60;/p&#62;
&#60;p&#62;The SD Card should be realitively easy now that the maple SD fat library is being worked on, something I'll be working on as well. Did you know that the Maple actually has an RTC built in? Doing maths on a low bit system isn't as bad as you'd might think, but certainly is slower. Especially, floating point. However, if you need floating point, do you really need all that accuracy? You could potentially use fixed point maths instead.&#60;/p&#62;
&#60;p&#62;Keep us update on the project, I'm sure quite a few people would be interested in seeing it!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Library porting question (PS2X_lib)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2428#post-12436</link>
			<pubDate>Wed, 15 Aug 2012 03:34:28 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">12436@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Awesome!  Thanks crenn.  I've never messed with SPI before, but might as well use hardware instead of software for this thing.  :)&#60;/p&#62;
&#60;p&#62;BTW, in case you are curious what I am up to, I am building a Go-To device for controlling a telescope mount and will have a large database of items on an SD card.  I already have the functions working that calculate current location in the sky for planets, moon, and a few major stars.  &#60;/p&#62;
&#60;p&#62;The device will have an alternate mode of operation where I can put it on a trivial mount made with two stepper motors and a gear drive so that the Maple can point a bright green laser at celestial objects, sort of like a planetarium guide, but using the actual sky.  With this ability, one can also determine location on the planet with a reliable time source (such as an RTC).  Even in the absence of an RTC, the device can calculate current date (but not accurate time) by finding a solution based upon the location of 2 or 3 planets.&#60;/p&#62;
&#60;p&#62;The reason that I stepped away from Arduino is because the 8bit math was pretty lame for doing high precision calculations.  Seven sig-figs makes me cry.  :(&#60;/p&#62;
&#60;p&#62;I can't wait to get this thing working and post some videos.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
