CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Arduino to CCS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

Arduino to CCS
PostPosted: Fri Jan 08, 2016 9:30 pm     Reply with quote

Hi,

I'm trying to test an arduino library with CCS.

Anyone knows the equivalent of shiftIn function in CCS?

Code:
byte incoming = shiftIn(dataPin, clockPin, bitOrder)

Example: data = shiftIn(SDO,SCK,MSBFIRST);



Thanks!
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Ttelmah



Joined: 11 Mar 2010
Posts: 19267

View user's profile Send private message

PostPosted: Sat Jan 09, 2016 2:38 am     Reply with quote

Use the CCS SPI functions.

On the Arduino, you generally use Shiftin, to perform the equivalent of SPI, on a pin that doesn't support the hardware SPI. It generates a clock and shifts a bit in from a pin (just like SPI).

The CCS SPI library supports operation both on the hardware peripheral, or on any pins using a software function. Both are built in to the single library. Nice thing is that the software functions this produces are tightly optimised.

So just declare the #USE SPI, to use the pins, edges, speed, bit order etc., and then use spi_xfer to get the byte or word.

CCS can also effectively shiftout at the same time, and spi_xfer can be told how many bits to shift (so you can for instance send/get 32bits in a single transaction. The CCS SPI functions also allow you to program the clock polarity, which edge to read on, the maximum rate to use etc.. The function can also be programmed to automatically operate CS if required (there is a _lot_ hidden in the CCS SPI library....).
Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group