You're being charged for the whole lot under a theory of constructive possession. That is, all of the drugs were in the car. You and your friend were also in the car, and everyone in the car can be charged with possession if they all could have had access to the drugs and could potentially share it.
Like any other legal presumption, the theory can fall when when the evidence comes out. So the fact that your friend confessed that the pills were just his would, if believed beyond a reasonable doubt, ultimately acquit you of that charge. Similiarly, if a jury believed that all the marijuana in the car was not meant to be shared, you'd ultimately only have to worry about beating the misdemeanor.
You need a lawyer for this case. You have the right to one, as well as the right to challenge the evidence and to confront the witnesses against you at hearings and trial, and to put the state to its burden of proof beyond a reasonable doubt.
People who ask "What rights do I have?" usually don't want to get a lecture on the Constitution. THey typically have a specific question in mind that they want to know. If I have not already answered that, please reply here on this question thread and let me know your actual question.